Skip to content

Commit

Permalink
fix: Allow the playback of TS without mux.js (#5041)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Feb 28, 2023
1 parent 2d0e4cc commit 0b785f7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/transmuxer/muxjs_transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ shaka.transmuxer.MuxjsTransmuxer = class {
this.muxjs_ = shaka.dependencies.muxjs();

/** @private {muxjs.mp4.Transmuxer} */
this.muxTransmuxer_ = new this.muxjs_.mp4.Transmuxer({
'keepOriginalTimestamps': true,
});
this.muxTransmuxer_ = null;

/** @private {shaka.util.PublicPromise} */
this.transmuxPromise_ = null;
Expand All @@ -46,9 +44,13 @@ shaka.transmuxer.MuxjsTransmuxer = class {
/** @private {boolean} */
this.isTransmuxing_ = false;

this.muxTransmuxer_.on('data', (segment) => this.onTransmuxed_(segment));

this.muxTransmuxer_.on('done', () => this.onTransmuxDone_());
if (this.muxjs_) {
this.muxTransmuxer_ = new this.muxjs_.mp4.Transmuxer({
'keepOriginalTimestamps': true,
});
this.muxTransmuxer_.on('data', (segment) => this.onTransmuxed_(segment));
this.muxTransmuxer_.on('done', () => this.onTransmuxDone_());
}
}


Expand All @@ -57,7 +59,9 @@ shaka.transmuxer.MuxjsTransmuxer = class {
* @export
*/
destroy() {
this.muxTransmuxer_.dispose();
if (this.muxTransmuxer_) {
this.muxTransmuxer_.dispose();
}
this.muxTransmuxer_ = null;
}

Expand Down Expand Up @@ -207,6 +211,8 @@ shaka.transmuxer.MuxjsTransmuxer = class {
* @export
*/
transmux(data) {
goog.asserts.assert(this.muxTransmuxer_,
'mux.js should be available.');
goog.asserts.assert(!this.isTransmuxing_,
'No transmuxing should be in progress.');
this.isTransmuxing_ = true;
Expand Down

0 comments on commit 0b785f7

Please sign in to comment.