Switch video element in Chromecast CAF Receiver

577 views Asked by At

I want to implement a custom CAF receiver that does the following:

  1. Plays a pre-roll ad video using an external ad SDK.
  2. Plays a DASH or HLS live stream.

The features work fine on their own. It is when I am playing a live stream after an ad that the player throws this error:

Uncaught DOMException: Failed to read the 'buffered' property from 'SourceBuffer': This SourceBuffer has been removed from the parent media source.
    at Hh.fk (http://www.gstatic.com/cast/sdk/libs/mediaplayer/1.0.0/media_player.js:149:315)
    at yc (http://www.gstatic.com/cast/sdk/libs/mediaplayer/1.0.0/media_player.js:30:291)
    at SourceBuffer.vc (http://www.gstatic.com/cast/sdk/libs/mediaplayer/1.0.0/media_player.js:31:343)
    at SourceBuffer.b (http://www.gstatic.com/cast/sdk/libs/mediaplayer/1.0.0/media_player.js:28:245)

This error is then followed by:

[cast.player.api.Host] error: cast.player.api.ErrorCode.PLAYBACK/104 

Error 104 indicates that the source is not supported by the player, but since the streams play fine without an ad, this cannot be the issue. It is most likely a side effect caused by the SourceBuffer error above.

I am certain that the cause of the error is with the video element that the Ad SDK used to display the pre-roll video. The Ad SDK adds the element, plays the ad, and removes the element afterwards.

I've tried the following:

  1. Set the video element inside the cast-media-player as the current playback element via context.getPlayerManager().setMediaElement(...) after the ad playback finished.
  2. Created the cast-media-player after the ad finished and added it to the body. Then requested the stream playback.
  3. A combination of 2→1: created the element and then set its video element as the current media element.

None of the above did work.

Is there a way to reset or re-init the player to use the cast-media-player element?

Note, that the ad-stitching supported by the CAF receiver is out of scope because the external ad SDK is a hard requirement.

0

There are 0 answers