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 f061c81
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/player/stream_video_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,9 @@ 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;
if (this.video.readyState >= HTMLMediaElement.HAVE_METADATA) {

This comment has been minimized.

Copy link
@joeyparrish

joeyparrish Jun 18, 2015

In the case of live streaming, this would not be enough. If the readyState is HAVE_NOTHING and we skip setting currentTime completely, live streams will not start properly. Their streamStartTimes are generally greater than 0. If the live stream has been running longer than its timeShiftBufferDepth parameter, starting at 0 is not possible (the segments are not available). Some live streams actually never had a segment at time 0 if they use offset since 1970 in the encoder.

So if the readyState is wrong, you will have to defer setting currentTime until the readyState is at least HAVE_METADATA, not skip it completely.

this.video.currentTime = streamStartTime;
}

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

0 comments on commit f061c81

Please sign in to comment.