Detecting when streams end and a subscriber's video is disabled

In this guide you will learn to detect when a stream ends. This allows you to perform any clean ups within your application as well as show your user any secondary screen, notifications etc.

When a subscriber's video is disabled, the OTSubscriber object dispatches a videoDisabled event:

When the Media Router disables the video of a subscriber, you may want to adjust the user interface related to the subscriber.

The reason property of the videoDisabled event object defines the reason the video was disabled. This can be set to one of the following values:

  • "PublisherPropertyChanged" — The publisher stopped publishing video.

  • "QualityChanged" — The Media Router stopped sending video to the subscriber based on stream quality changes. This feature of the Media Router has a subscriber drop the video stream when connectivity degrades. (The subscriber continues to receive the audio stream, if there is one.)

Before sending this event, when the subscriber's stream quality deteriorates to a level that is low enough that the video stream is at risk of being disabled, the OTSubscriber objet dispatches a videoDisableWarning event.

If connectivity improves to support video again, the OTSubscriber object dispatches a videoEnabled event, and the subscriber resumes receiving video.

This feature is only available in sessions that use the Media Router (sessions with the media mode set to routed), not in sessions with the media mode set to relayed.

When you publish a stream, you can prevent it from having its video disabled due to stream quality. Set audioFallbackEnabled to false in the properties prop pass into the OTPublisher component.

  • "SubscriberPropertyChanged" — The subscriber started or stopped subscribing to video, by setting subscribeToVideo to false in the properties prop passed into the OTSubscriber component.

  • "CodecNotSupported" — The subscriber stopped subscribing to video due to an incompatible codec (see the Video codecs developer guide).

The OTSubscriber object dispatches videoEnabled event when video resumes:

The reason property of the videoEnabled event object defines the reason the video was enabled. This can be set to one of the following values:

  • "PublisherPropertyChanged" — The publisher resumed publishing video.

  • "QualityChanged" — The Media Router resumed sending video to the subscriber based on stream quality changes. This feature of the Media Router has a subscriber drop the video stream when connectivity degrades and then resume the video stream if the stream quality improves.

This feature is only available in sessions that use the Media Router (sessions with the media mode set to routed), not in sessions with the media mode set to relayed.

  • "SubscriberPropertyChanged" — The subscriber started or stopped subscribing to video, by setting subscribeToVideo to false in the properties prop passed into the OTSubscriber component.

  • "CodecNotSupported" — The subscriber video was enabled after a codec change from an incompatible codec (see the Video codecs developer guide).