Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: calling detatchMedia() followed by attachMedia() causes audio to not play #2303

Merged
merged 9 commits into from
Oct 8, 2019
Merged
1 change: 1 addition & 0 deletions src/controller/audio-stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ class AudioStreamController extends BaseStreamController {
}
this.media = this.mediaBuffer = this.videoBuffer = null;
this.loadedmetadata = false;
this.fragmentTracker.removeAllFragments();
this.stopLoad();
}

Expand Down
5 changes: 5 additions & 0 deletions src/controller/buffer-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class BufferController extends EventHandler {
// signals that mediaSource should have endOfStream called
private _needsEos: boolean = false;

// Track whether the parsed manifest signaled alternate audio
private _altAudio: boolean = false;
OrenMe marked this conversation as resolved.
Show resolved Hide resolved

private config: BufferControllerConfig;

// this is optional because this property is removed from the class sometimes
Expand Down Expand Up @@ -143,6 +146,7 @@ class BufferController extends EventHandler {
// sourcebuffers will be created all at once when the expected nb of tracks will be reached
// in case alt audio is not used, only one BUFFER_CODEC event will be fired from main stream controller
// it will contain the expected nb of source buffers, no need to compute it
this._altAudio = data.altAudio;
OrenMe marked this conversation as resolved.
Show resolved Hide resolved
this.bufferCodecEventsExpected = data.altAudio ? 2 : 1;
logger.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`);
}
Expand Down Expand Up @@ -202,6 +206,7 @@ class BufferController extends EventHandler {
this.mediaSource = null;
this.media = null;
this._objectUrl = null;
this.bufferCodecEventsExpected = this._altAudio ? 2 : 1;
OrenMe marked this conversation as resolved.
Show resolved Hide resolved
this.pendingTracks = {};
this.tracks = {};
this.sourceBuffer = {};
Expand Down
2 changes: 2 additions & 0 deletions src/controller/stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ class StreamController extends BaseStreamController {
media.removeEventListener('ended', this.onvended);
this.onvseeking = this.onvseeked = this.onvended = null;
}
this.fragmentTracker.removeAllFragments();
OrenMe marked this conversation as resolved.
Show resolved Hide resolved
this.media = this.mediaBuffer = null;
this.loadedmetadata = false;
this.stopLoad();
Expand Down Expand Up @@ -735,6 +736,7 @@ class StreamController extends BaseStreamController {
logger.log('both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC');
}

this.altAudio = data.altAudio;
OrenMe marked this conversation as resolved.
Show resolved Hide resolved
this.levels = data.levels;
this.startFragRequested = false;
let config = this.config;
Expand Down