Pages Menu

Posted by on Jun 3, 2015 in Learn Skype Web SDK | 1 comment

Learn Skype Web SDK Day 25 : Listing & Changing Devices

Learn Skype Web SDK Day 25 : Listing & Changing Devices

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

You can make or receive audio and video calls with Skype Web SDK without ever worrying about what devices are going to be used – by default Skype Web SDK will choose some sensible defaults for you. However, eventually your users might wonder why they can’t select a different webcam, or you may want to offer them the option of switching between devices.

Preview Code Alert! – At the time of writing, the code on this page didn’t appear to work with Google Chrome. In addition, when used in Internet Explorer, some inconsistencies were seen with the list of speakers, with some devices being listed twice. Expect this to be resolved when the SDK goes to GA – but for now it’s something you’ll want to be aware of.

The chosen camera, microphone and speaker are managed in Skype Web SDK by the devicesManager. This object is accessible from the main client object, and lets you see:

  • a list of all cameras, microphones & speakers available to Skype Web SDK
  • the currently selected camera, microphone & speaker
  • events when cameras, microphones or speakers are added, removed, or the select device is changed
  • the ability to change the selected device

Like the rest of the SDK, this information is only surfaced when you ask for it and arrives asynchronously. Therefore, to build up a list of available cameras, you would first listen for the cameras.added event, then subscribe to the cameras collection:

[code language=”javascript”]
client.devicesManager.cameras.added(function (newCamera) {



You can listen for selectedCamera in exactly the same way. The call to cameras.subscribe will ensure that the selectedCamera.changed event is also fired.

You can also subscribe to the cameras.removed event to receive notification of when the camera is no longer available (maybe it’s been pulled out or turned off!). If you’re maintaining a list of devices in your Skype Web SDK application this information will likely be useful.

To change the current camera you just set the selectedCamera object with the camera object you want to switch to. It’s that simple!

Listing and Changing using the microphones and speakers objects are exactly the same, with selectedMicrophone and selectedSpeaker objects.

The code sample for this post lists the currently selected camera, microphone and speaker. All available devices are also listed in drop-downs, and choosing a different device will make that device the selected device. For simplicity devices being removed isn’t supported in the example (but could be easily added):

[code language=”javascript”]

Selected Camera:
Selected Microphone:
Selected Speaker:


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

1 Comment

  1. News – MSN

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).