This repository has been archived by the owner on Jan 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 793
Seek to a safe position when resuming live playlists #327
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -321,12 +321,21 @@ videojs.Hls.prototype.play = function() { | |
this.mediaIndex = 0; | ||
} | ||
|
||
// seek to the latest safe point in the media timeline when first | ||
// playing live streams | ||
if (this.duration() === Infinity && | ||
this.playlists.media() && | ||
!this.player().hasClass('vjs-has-started')) { | ||
this.setCurrentTime(this.seekable().end(0)); | ||
// we may need to seek to begin playing safely for live playlists | ||
if (this.duration() === Infinity) { | ||
|
||
// if this is the first time we're playing the stream or we're | ||
// ahead of the latest safe playback position, seek to the live | ||
// point | ||
if (!this.player().hasClass('vjs-has-started') || | ||
this.currentTime() > this.seekable().end(0)) { | ||
this.setCurrentTime(this.seekable().end(0)); | ||
|
||
} else if (this.currentTime() < this.seekable().start(0)) { | ||
// if the viewer has paused and we fell out of the live window, | ||
// seek forward to the earliest available position | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in this case, do we want to seek to the earliest position or to the "3 segments behind live"/"live point" position? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This way the viewer misses the minimum amount of content relative to when they paused the broadcast. The choice is a bit subjective but I think this is defensible. |
||
this.setCurrentTime(this.seekable().start(0)); | ||
} | ||
} | ||
|
||
// delegate back to the Flash implementation | ||
|
@@ -356,6 +365,13 @@ videojs.Hls.prototype.setCurrentTime = function(currentTime) { | |
return 0; | ||
} | ||
|
||
// clamp seeks to the available seekable time range | ||
if (currentTime < this.seekable().start(0)) { | ||
currentTime = this.seekable().start(0); | ||
} else if (currentTime > this.seekable().end(0)) { | ||
currentTime = this.seekable().end(0); | ||
} | ||
|
||
// save the seek target so currentTime can report it correctly | ||
// while the seek is pending | ||
this.lastSeekedTime_ = currentTime; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about storing seekable end in a variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe calculating seekable end is expensive enough to worry about caching.