JavaScript

Subscribing to audio or video only

When you subscribe to a stream, you can specify whether to initially subscribe to audio or video (if they are available). For example, the following code subscribes to the audio stream only:

After you create a Subscriber object, you toggle audio on or off by calling the subscribeToAudio() method of the Subscriber object:

You toggle video on or off by calling the subscribeToVideo() method of the Subscriber object:

Note however that you can only subscribe to audio or video if the client publishing the stream includes audio or video. For example, calling subscribeToVideo(false) will have no effect if the client publishing the stream is publishing audio only.

Changing the audio level of a subscriber

When you subscribe to a stream, you can set the initial volume of the subscriber when you call the subscribe() method of the Session object:

After you create a Subscriber object, you can set its volume by calling its setAudioVolume() method, passing in a value from 0 (silent) to 100 (full volume):

Note that the user can also mute the subscriber via user interface controls in the subscriber.