C# skype用于业务外呼和播放音频文件

C# skype用于业务外呼和播放音频文件,c#,phone-call,skype-for-business,C#,Phone Call,Skype For Business,目标是开发一个模块的系统监控解决方案接口,该模块调用待命值班人员并播放文件系统中的一些语音/音频文件 我有一个skype for business 2015(fomerly lync)用户,启用了电话选项。我也能打一个电话号码。但问题是,如何等到被叫人接听电话并播放音频文件(或者更好的是使用System.Speech变体而不是播放音频文件),然后该人必须批准他/她接听了电话 我目前拥有的: public void SendLyncCall(string numberToCall, string

目标是开发一个模块的系统监控解决方案接口,该模块调用待命值班人员并播放文件系统中的一些语音/音频文件

我有一个skype for business 2015(fomerly lync)用户,启用了电话选项。我也能打一个电话号码。但问题是,如何等到被叫人接听电话并播放音频文件(或者更好的是使用System.Speech变体而不是播放音频文件),然后该人必须批准他/她接听了电话

我目前拥有的:

public void SendLyncCall(string numberToCall, string textToSpeech)
{
  var targetContactUris = new List<string> {numberToCall}; //"tel:+4900000000" }; //removed here

  _automation.BeginStartConversation(AutomationModalities.Audio, targetContactUris, null, StartConversationCallback, null);

    while (this.globalConv == null)
    {
      Thread.Sleep(1);
    }
  if (globalConv != null)
  {
    LyncClient client = LyncClient.GetClient();

    client.DeviceManager.EndPlayAudioFile(
      client.DeviceManager.BeginPlayAudioFile(@"d:\tmp\test1.wav",
        AudioPlayBackModes.Communication,
        false,
        null,
        null));
  }
}

private void StartConversationCallback(IAsyncResult asyncop)
{
 // this is called once the dialing completes..
if (asyncop.IsCompleted == true)
{

    ConversationWindow newConversationWindow = _automation.EndStartConversation(asyncop);
  globalConv = newConversationWindow;
    AVModality avModality = globalConv.Conversation.Modalities[ModalityTypes.AudioVideo] as AVModality;


    foreach (char c in "SOS")
    {
      avModality.AudioChannel.BeginSendDtmf(c.ToString(), null, null);
      System.Threading.Thread.Sleep(300);
    }

  }
}
public void SendLyncCall(字符串numberToCall,字符串textospeech)
{
var targetContactUris=新列表{numberToCall};/“电话:+490000000”}//移到这里
_automation.begintarconversation(automationmodelities.Audio、targetContactUris、null、StartConversationCallback、null);
while(this.globalConv==null)
{
睡眠(1);
}
if(globalConv!=null)
{
LyncClient=LyncClient.GetClient();
client.DeviceManager.endPlayAudio文件(
client.DeviceManager.BeginPlayAudioFile(@“d:\tmp\test1.wav”,
音频播放模式,通讯,
假,,
无效的
空);
}
}
私有void StartConversationCallback(IAsyncResult异步操作)
{
//一旦拨号完成,就会调用此命令。。
if(asyncop.IsCompleted==true)
{
ConversationWindow newConversationWindow=\u automation.EndStartConversation(异步操作);
globalConv=新建对话窗口;
AVMODULE AVMODULE=globalConv.Conversation.modules[modalitypes.AudioVideo]作为AVMODULE;
foreach(SOS中的字符c)
{
avModality.AudioChannel.BeginSendDtmf(c.ToString(),null,null);
系统.线程.线程.睡眠(300);
}
}
}
另一个问题是,是否可以将整个模块更改为可以作为windows服务运行的已注册端点?目前,我的sfb必须打开并登录。

请注意,这不是您发布的代码,而是代码

我将假设您想知道如何使用Lync Client SDK执行所要求的操作

您需要挂接事件,以了解它何时更改为AVModality.State

一旦处于连接状态,您就可以做您想做的事情

调整我想到的代码:

private void StartConversationCallback(IAsyncResult asyncop)
{
    // this is called once the dialing completes..
    if (asyncop.IsCompleted == true)
    {
        ConversationWindow newConversationWindow = _automation.EndStartConversation(asyncop);
        AVModality avModality = newConversationWindow.Conversation.Modalities[ModalityTypes.AudioVideo] as AVModality;
        avModality.ModalityStateChanged += ConversationModalityStateChangedCallback;
    }
}

private void ConversationModalityStateChangedCallback(object sender, ModalityStateChangedEventArgs e)
{
    AVModality avModality = sender as AVModality;
    if (avModality != null)
    {
        switch (e.NewState)
        {
            case ModalityState.Disconnected:
                avModality.ModalityStateChanged -= ConversationModalityStateChangedCallback;
                break;

            case ModalityState.Connected:
                avModality.ModalityStateChanged -= ConversationModalityStateChangedCallback;
                foreach (char c in "SOS")
                {
                    avModality.AudioChannel.BeginSendDtmf(c.ToString(), null, null);
                    System.Threading.Thread.Sleep(300);
                }
                break;
        }
    }
}
请注意,这不是您发布的代码,而是代码

我将假设您想知道如何使用Lync Client SDK执行所要求的操作

您需要挂接事件,以了解它何时更改为AVModality.State

一旦处于连接状态,您就可以做您想做的事情

调整我想到的代码:

private void StartConversationCallback(IAsyncResult asyncop)
{
    // this is called once the dialing completes..
    if (asyncop.IsCompleted == true)
    {
        ConversationWindow newConversationWindow = _automation.EndStartConversation(asyncop);
        AVModality avModality = newConversationWindow.Conversation.Modalities[ModalityTypes.AudioVideo] as AVModality;
        avModality.ModalityStateChanged += ConversationModalityStateChangedCallback;
    }
}

private void ConversationModalityStateChangedCallback(object sender, ModalityStateChangedEventArgs e)
{
    AVModality avModality = sender as AVModality;
    if (avModality != null)
    {
        switch (e.NewState)
        {
            case ModalityState.Disconnected:
                avModality.ModalityStateChanged -= ConversationModalityStateChangedCallback;
                break;

            case ModalityState.Connected:
                avModality.ModalityStateChanged -= ConversationModalityStateChangedCallback;
                foreach (char c in "SOS")
                {
                    avModality.AudioChannel.BeginSendDtmf(c.ToString(), null, null);
                    System.Threading.Thread.Sleep(300);
                }
                break;
        }
    }
}

上面的代码看起来您使用的是Lync Client SDK,而不是UCMA。谢谢。我从收割台上取下数据。lync client完全错误地认为应该作为服务运行。现在我将使用ucma 5.0。上面的代码看起来像是在使用Lync Client SDK,而不是ucma。谢谢。我从收割台上取下数据。lync client完全错误地认为应该作为服务运行。我现在就用ucma 5.0。如上所述:lyncclient是错误的方法。感谢您提供状态检查。但将与ucma一起作为服务运行。thx。如上所述:lyncclient是错误的方法。感谢您提供状态检查。但将与ucma一起作为服务运行。