873a2dd7 by Brandon Bay

Setting start position on a live stream

Live start position should be 30s before live, not at the beginning of
the stream playlist.
1 parent 61566277
...@@ -141,6 +141,13 @@ videojs.Hls.prototype.handleSourceOpen = function() { ...@@ -141,6 +141,13 @@ videojs.Hls.prototype.handleSourceOpen = function() {
141 segmentDlTime = Infinity; 141 segmentDlTime = Infinity;
142 } 142 }
143 143
144 if(this.duration() === Infinity) {
145 var lookback = Math.round(30 / segmentDuration);
146 if (selectedPlaylist.segments.length > lookback) {
147 this.mediaIndex = selectedPlaylist.segments.length - lookback;
148 }
149 }
150
144 // this threshold is to account for having a high latency on the manifest 151 // this threshold is to account for having a high latency on the manifest
145 // request which is a somewhat small file. 152 // request which is a somewhat small file.
146 threshold = 10; 153 threshold = 10;
...@@ -801,7 +808,7 @@ videojs.Hls.translateMediaIndex = function(mediaIndex, original, update) { ...@@ -801,7 +808,7 @@ videojs.Hls.translateMediaIndex = function(mediaIndex, original, update) {
801 } 808 }
802 809
803 // sync on media sequence 810 // sync on media sequence
804 return (original.mediaSequence + mediaIndex) - update.mediaSequence; 811 return (update.mediaSequence + mediaIndex) - original.mediaSequence;
805 }; 812 };
806 813
807 /** 814 /**
......