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

Live playlist loading improvements #274

Closed
wants to merge 2 commits into from

Conversation

ntadej
Copy link

@ntadej ntadej commented May 20, 2015

We managed to fix the problems described in #236. This PR consists of two commits.

The repetition of chunks was caused because media index didn't need to be translated when changing quality. The playlist was the same and translation should not occur.

The second commit fixes crazy loading of playlists and chunks after several quality changes as timeouts accumulated and produced more and more requests.

@@ -94,6 +94,7 @@

// refresh live playlists after a target duration passes
if (!loader.media().endList) {
window.clearTimeout(mediaUpdateTimeout);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This had to be a huge pain to track down. Thank you!

@ntadej
Copy link
Author

ntadej commented May 22, 2015

Updated PR according to your comments.

@@ -1035,7 +1035,7 @@ videojs.Hls.translateMediaIndex = function(mediaIndex, original, update) {
// bitrate switches should be happening here.
translatedMediaIndex = (mediaIndex + (original.mediaSequence - update.mediaSequence));

if (translatedMediaIndex >= update.segments.length || translatedMediaIndex < 0) {
if (translatedMediaIndex > update.segments.length || translatedMediaIndex < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't feel right. Segments is a 0-indexed array, so update.segments.length is an out-of-bounds element. Why is this necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When all the segments currently available in a live playlist have been downloaded, mediaIndex will point to one beyond the end. There's nothing wrong with this situation, we're just waiting for a playlist refresh. It's incorrect to reset mediaIndex back to the live point if this occurs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants