Using segment length (not average) to snap to live
Counts segments using their individual duration to look back 30s from live to set video start position
Showing
1 changed file
with
7 additions
and
4 deletions
... | @@ -141,11 +141,14 @@ videojs.Hls.prototype.handleSourceOpen = function() { | ... | @@ -141,11 +141,14 @@ videojs.Hls.prototype.handleSourceOpen = function() { |
141 | segmentDlTime = Infinity; | 141 | segmentDlTime = Infinity; |
142 | } | 142 | } |
143 | 143 | ||
144 | if(this.duration() === Infinity) { | 144 | if(this.duration() === Infinity && this.mediaIndex === 0) { |
145 | var lookback = Math.round(30 / segmentDuration); | 145 | var i = selectedPlaylist.segments.length - 1; |
146 | if (selectedPlaylist.segments.length > lookback) { | 146 | var tailDuration = 0; |
147 | this.mediaIndex = selectedPlaylist.segments.length - lookback; | 147 | while (tailDuration < 30 && i > 0) { |
148 | tailDuration += selectedPlaylist.segments[i].duration; | ||
149 | i--; | ||
148 | } | 150 | } |
151 | this.mediaIndex = i; | ||
149 | } | 152 | } |
150 | 153 | ||
151 | // this threshold is to account for having a high latency on the manifest | 154 | // this threshold is to account for having a high latency on the manifest | ... | ... |
-
Please register or sign in to post a comment