Add or remove video in a conversation

Applies to: Skype for Business 2015

In this article
Add video to a conversation
Remove video from a conversation
Subscribe to changes from the videoService in a conversation
Accept video without sending video

With an existing conversation instance, video can be added or removed.

Add video to a conversation

conversation.videoService.start().then(function () {
  // Successfully added video to the conversation
  // Set the video window container
  conversation.selfParticipant.video.channels(0).container(document.getElementById("renderWindow"));
  channel.isStarted.set(true);
});

You may also set the video window container prior to starting the videoService.

// Set the video window container
conversation.selfParticipant.video.channels(0).container(document.getElementById("renderWindow"));
conversation.videoService.start().then(function () {
  // Successfully added video to the conversation
  conversation.selfParticipant.video.channels(0).isStarted.set(true);
});

Note: Setting the video container more than one time for the same video stream will cause problems with video playback.

Remove video from a conversation

Conversation.videoService.stop().then(function () {
  // Successfully removed video from the conversation
});

Video can also be removed by stopping the audioService.

Conversation.audioService.stop().then(function () {
  // Successfully removed audio and video from the conversation
});

Subscribe to changes from the videoService in a conversation

An event is fired when the client has successfully added video to the conversation, or another participant has invited the client to add video.

  1. Subscribe to the event.

    conversation.selfParticipant.video.state.changed(function (val) {
    …
    });
    
  2. If the val argument in the previous snippet indicates the event is an invitation to add video, the client may reject or accept the invitation.

    if (val == 'Notified') {
     if (confirm('Accept incoming video request?')) {
         console.log('accepting the incoming video request');
         conversation.videoService.accept();
         console.log('Accepting incoming video request');
     }
     else {
         console.log('declining the incoming video request');
         conversation.videoService.reject();
     }
    }
    

Accept video without sending video

Clients can accept requests for video without sending their own video by calling audioService.accept().

  1. Subscribe to the video state changed event.

    conversation.selfParticipant.video.state.changed(function (val) {
    …
    });
    
  2. If the val argument in the previous snippet indicates the event is an invitation to add video, the client may accept the invitation without sending the client's video.

    if (val == 'Notified') {
     conversation.audioService.accept();
    }
    
  3. The client's video can be added later.

    conversation.selfParticipant.video.channels(0).isStarted(true);