Skip to content

Commit

Permalink
Do not assign currentTime of video unless MetaData is available.
Browse files Browse the repository at this point in the history
Fixes shaka-project#101
Required for Firefox's and IE's MediaElement implementations.
  • Loading branch information
Nick Desaulniers committed Jun 18, 2015
1 parent 96b369e commit 5583779
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/player/stream_video_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,17 @@ shaka.player.StreamVideoSource.prototype.startStreams_ = function(
// Set the video's current time before starting the streams so that the
// streams begin buffering at the stream start time.
shaka.log.info('Starting each stream from', streamStartTime);
this.video.currentTime = streamStartTime;

function setInitialCurrentTime() {
this.currentTime = streamStartTime;
this.removeEventListener('loadedmetadata', setInitialCurrentTime);
}

if (this.video.readyState >= HTMLMediaElement.HAVE_METADATA) {
this.currentTime = streamStartTime;
} else {
this.video.addEventListener('loadedmetadata', setInitialCurrentTime);
}

// Start the streams.
for (var type in this.streamsByType_) {
Expand Down

0 comments on commit 5583779

Please sign in to comment.