Skip to content

Commit

Permalink
fix: Do not allow MSE operations when using Remote Playback (#7503)
Browse files Browse the repository at this point in the history
Related to #5022
  • Loading branch information
avelad authored Oct 25, 2024
1 parent e14a8eb commit b04caa3
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ shaka.media.MediaSourceEngine = class {
/** @private {boolean} */
this.playbackHasBegun_ = false;

/** @private {boolean} */
this.streamingAllowed_ = true;

/** @private {boolean} */
this.usingRemotePlayback_ = false;

/** @private {HTMLSourceElement} */
this.source_ = null;

Expand Down Expand Up @@ -148,9 +154,6 @@ shaka.media.MediaSourceEngine = class {
/** @private {boolean} */
this.needSplitMuxedContent_ = false;

/** @private {boolean} */
this.streamingAllowed_ = true;

/** @private {?number} */
this.lastDuration_ = null;

Expand All @@ -171,6 +174,22 @@ shaka.media.MediaSourceEngine = class {

/** @private {!shaka.util.PublicPromise.<number>} */
this.audioCompensation_ = new shaka.util.PublicPromise();

if (this.video_.remote) {
this.usingRemotePlayback_ = this.video_.remote.state != 'disconnected';

this.eventManager_.listen(this.video_.remote, 'connect', () => {
this.usingRemotePlayback_ = this.video_.remote.state != 'disconnected';
});

this.eventManager_.listen(this.video_.remote, 'connecting', () => {
this.usingRemotePlayback_ = this.video_.remote.state != 'disconnected';
});

this.eventManager_.listen(this.video_.remote, 'disconnect', () => {
this.usingRemotePlayback_ = this.video_.remote.state != 'disconnected';
});
}
}

/**
Expand Down Expand Up @@ -635,7 +654,7 @@ shaka.media.MediaSourceEngine = class {
* @return {boolean}
*/
isStreamingAllowed() {
return this.streamingAllowed_;
return this.streamingAllowed_ && !this.usingRemotePlayback_;
}

/**
Expand Down Expand Up @@ -774,7 +793,7 @@ shaka.media.MediaSourceEngine = class {
* @private
*/
getBuffered_(contentType) {
if (this.reloadingMediaSource_) {
if (this.reloadingMediaSource_ || this.usingRemotePlayback_) {
return null;
}
try {
Expand Down

0 comments on commit b04caa3

Please sign in to comment.