Pages Menu
TwitterRssFacebook

Posted by on May 27, 2015 in Learn Skype Web SDK | 2 comments

Learn Skype Web SDK Day 20 : Starting a New Audio Conversation

Learn Skype Web SDK Day 20 : Starting a New Audio Conversation

This is one post in a series of more than 30, devoted to helping you get up to speed quickly with the new Skype Web SDK. Each lesson comes with source code (in GitHub) and a working demo page so you can see what it does. Check out the full list of posts on the Skype Web SDK page.


View Demo

Starting an audio call using Skype for Web API is very similar to starting an Instant Message conversation. The actual setup of the conversation and adding participants is identical – in fact the only real difference is that instead of starting the Chat Service, we start the Audio Service.

Conversations are started, stopped and managed from the conversationManager, which is a member of the top-level parent Application. Creating a new conversation with Skype for Web API is actually a lot easier than you might think. It consists of 4 distinct steps: create the conversation, add participants, register the new conversation, start the conversation.

In order to make audio calls, you need to make sure the Plugin is installed.

Step 1 – Create the conversation. Like the rest of Skype for Web API – new objects are not ever instantiated in isolation – they always come from a parent. In this case we use the parent conversationManager to create a new conversation:

[code language=”javascript”]
var application;
//instantiate application object and do sign-in process
var conversation = application.conversationsManager.createConversation();
[/code]

Step 2 – Add the participants. You don’t need to add yourself, but you need to add anyone else in the conversation. Assuming you already have the person object:

[code language=”javascript”]
var conversationParticipant = conversation.createParticipant(person);
conversation.participants.add(conversationParticipant);
[/code]

Step 3 – Register the conversation. Before you start the conversation you need to tell the conversationsManager about it by adding it into its list of conversation:

[code language=”javascript”]
application.conversationsManager.conversations.add(conversation);
[/code]

Step 4 – Start the conversation! You’re now ready to begin the Audio Service, which you do with:

[code language=”javascript”]
conversation.audioService.start();
[/code]

At this point, the remote participant will receive the incoming conversation. So that you can track whether they answer it, or ignore/reject it you need to know its state. You can get this by subscribing to state change events on the local participants audio state:

[code language=”javascript”]
conversation.selfParticipant.audio.state.changed(function(newState) {
//do something with newState
});
[/code]

Once you start the audioService the state will change to “Connecting”. When the remote participant accepts, the state will change to “Connected”. If they reject or ignore the call it will change to “Disconnected”.

If you find that the state goes staight to “Disconnected” immediately without contacting the remote participant, have a look at the Console Log. If there’s been an error you should find it there. For instance, your Log list might look like this:

AudioVideoModality(a5df8786)::state: Created -> Connecting Reason: undefined

PluginManager::init - id = __mainPluginManager_e51d94cc_cd85_4263_ab0f_2e7cad9c819b

PluginManager::onPluginObjectState None
PluginManager::init - creating inner object
PluginObject::createInnerObject __mainPluginManager_e51d94cc_cd85_4263_ab0f_2e7cad9c819b_0

PluginManager::onPluginObjectState NotInstalled
PluginManager::cleanupPluginObject

PluginObject::destroyInnerObject __mainPluginManager_e51d94cc_cd85_4263_ab0f_2e7cad9c819b_0
PluginObject::cleanup __mainPluginManager_e51d94cc_cd85_4263_ab0f_2e7cad9c819b_0
AudioVideoSession(cc2e6069-6bb8-46ea-be68-8fa83373942a) State: Connecting -> Disconnected

AudioVideoModality(a5df8786)::state: Connecting -> Disconnected Reason: undefined

Here it’s pretty easy to see that the Plugin isn’t installed.

Today’s example code shows how to start an audio conversation using Skype Web SDK:

[code language=”javascript”]




[/code]

Demo Online

You can try this code out against your own Skype for Business environment by going to the demo page. From here you can also download the code from GitHub if you want to host it locally, or take it and use it in your next project.

Disclaimer: This is sample code, intended to inform and educate. It is not production-ready and is lacking key components such as error handling. You use it entirely at your own risk. You should fully understand the effects, limitations and risks of the code before executing, and understand the implications of any set-up steps. By using these code examples you are using the Skype Web SDK, so you should read the Skype Software License Terms to which you are agreeing.

Good to Know

2 Comments

  1. Hi Tom
    Can you please tell what is the Plugin it is looking for. We have Skype for business Client installed on our systems but still getting error message that Plugin not installed. Your help is highly appreciated.

  2. hey tom,

    i too am having the same issue with the console showing that the plugin is not installed… in any browser, even though i know for sure it is as i use it for testing joining meetings over the web.

    any ideas?

    thanks!

Post a Reply

Your email address will not be published. Required fields are marked *

This site uses cookies to help make this website better. By continuing to use this site we’ll assume you’re OK with that (implied consent).