Skip to content

Commit

Permalink
Fix double Promise resolution in TextStream.
Browse files Browse the repository at this point in the history
Change-Id: I7fe6de135775afa10c081a9d7d7b308e46c6b486
  • Loading branch information
Timothy Drews authored and Gerrit Code Review committed Aug 21, 2015
1 parent e02f74a commit 47948f4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/media/text_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,15 @@ shaka.media.TextStream.prototype.switch = function(
return;
}

this.streamInfo_ = streamInfo;
this.segmentIndex_ = segmentIndex;

if (segmentIndex.length() == 0) {
return Promise.reject(new Error('No subtitles URL available.'));
}

var previousStreamInfo = this.streamInfo_;

this.streamInfo_ = streamInfo;
this.segmentIndex_ = segmentIndex;

// TODO: Add support for failover in subtitles?
var subtitlesUrl = segmentIndex.first().url.urls[0].toString();

Expand Down Expand Up @@ -164,7 +166,9 @@ shaka.media.TextStream.prototype.switch = function(
var event = shaka.media.TextStream.createAdaptationEvent_(streamInfo);
this.dispatchEvent(event);

this.startedPromise_.resolve(0 /* timestampCorrection */);
if (!previousStreamInfo) {
this.startedPromise_.resolve(0 /* timestampCorrection */);
}
}));
};

Expand Down

0 comments on commit 47948f4

Please sign in to comment.