Skip to content

Commit

Permalink
fix AudioStreamController when media is not attached (video-dev#2172)
Browse files Browse the repository at this point in the history
  • Loading branch information
mad-gooze authored and johnBartos committed Apr 10, 2019
1 parent 496fd10 commit fee971c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/controller/audio-stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,8 @@ class AudioStreamController extends BaseStreamController {

let audioSwitch = this.audioSwitch, media = this.media, appendOnBufferFlush = false;
// Only flush audio from old audio tracks when PTS is known on new audio track
if (audioSwitch && media) {
if (media.readyState) {
if (audioSwitch) {
if (media && media.readyState) {
let currentTime = media.currentTime;
logger.log('switching audio track : currentTime:' + currentTime);
if (currentTime >= data.startPTS) {
Expand Down Expand Up @@ -699,7 +699,9 @@ class AudioStreamController extends BaseStreamController {
stats.tbuffered = performance.now();
hls.trigger(Event.FRAG_BUFFERED, { stats: stats, frag: frag, id: 'audio' });
let media = this.mediaBuffer ? this.mediaBuffer : this.media;
logger.log(`audio buffered : ${TimeRanges.toString(media.buffered)}`);
if (media) {
logger.log(`audio buffered : ${TimeRanges.toString(media.buffered)}`);
}
if (this.audioSwitch && this.appended) {
this.audioSwitch = false;
hls.trigger(Event.AUDIO_TRACK_SWITCHED, { id: this.trackId });
Expand Down

0 comments on commit fee971c

Please sign in to comment.