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 and joeyparrish committed Mar 1, 2023
1 parent 4fd078e commit 5784250
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/media/transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ shaka.media.Transmuxer = 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 @@ -48,16 +46,22 @@ shaka.media.Transmuxer = 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_());
}
}

/**
* @override
*/
destroy() {
this.muxTransmuxer_.dispose();
if (this.muxTransmuxer_) {
this.muxTransmuxer_.dispose();
}
this.muxTransmuxer_ = null;
return Promise.resolve();
}
Expand Down Expand Up @@ -156,6 +160,8 @@ shaka.media.Transmuxer = class {
* metadata: !Array.<!Object>}>}
*/
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 5784250

Please sign in to comment.