Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Commit

Permalink
Only use seekable if we know it's not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
jforbes committed Sep 20, 2017
1 parent 27bce9c commit 8e38b50
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/playback-watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,19 @@ export default class PlaybackWatcher {
fixesBadSeeks_() {
const seeking = this.tech_.seeking();
const seekable = this.seekable();
const seekableStart = seekable.start(0);
const seekableEnd = seekable.end(seekable.length - 1);
const currentTime = this.tech_.currentTime();
let seekTo;

if (seeking && this.afterSeekableWindow_(seekable, currentTime)) {
const seekableStart = seekable.start(0);

// sync to live point (if VOD, our seekable was updated and we're simply adjusting)
seekTo = seekableEnd;
}

if (seeking && this.beforeSeekableWindow_(seekable, currentTime)) {
const seekableEnd = seekable.end(seekable.length - 1);

// sync to the beginning of the live window
// provide a buffer of .1 seconds to handle rounding/imprecise numbers
seekTo = seekableStart + 0.1;
Expand Down

0 comments on commit 8e38b50

Please sign in to comment.