商业呼出电话的Skype并播放音频文件 [英] skype for business outgoing call and play audio file

查看:124
本文介绍了商业呼出电话的Skype并播放音频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标是为模块开发系统监视解决方案的接口,该模块将呼叫值班人员并播放文件系统中的某些语音/音频文件.

Goal is to develop an interface of a systems monitoring solution to a module, which calls an on-call duty person and plays some speech/audio file from file system.

我有一个启用了电话选项的2015年商务版Skype(Flylyly Lync)用户.我也可以给电话打个电话.但是然后的问题是,如何等待被叫方接听电话并播放音频文件(或者最好是System.Speech变体而不是播放音频文件),然后此人必须批准他/她接到电话.

i have an skype for business 2015 (fomerly lync) user with phone options enabled. i am also able to call phone a number. but then the question is, how to wait until the dialed person accepts the phone call and play an audio file (or better is the System.Speech variant instead of playing an audio file) and after that the person has to approve that he/she received the call.

我目前有什么:

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);
    }

  }
}

另一个问题是,是否可以将整个模块更改为可以作为Windows服务运行的注册端点?目前,我的sfb必须打开并登录.

and the other question is, is it possible to change whole module to be a registered endpoint that it can run as a windows service? Currently my sfb has to be opened and logged in..

推荐答案

请注意,这不是 Lync客户端SDK 代码.

Please note this is NOT UCMA code you posted, it's Lync Client SDK code.

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

I'm going to assume you want to know how to do what you ask with the Lync Client SDK.

您需要挂钩

You need to hook the AVModality.ModalityStateChanged event to see know when it changes to the AVModality.State changes to Connected.

处于已连接"状态后,您可以执行所需的操作.

Once in the Connected state, you can do what you want.

调整您想出的代码:

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;
        }
    }
}

这篇关于商业呼出电话的Skype并播放音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆