912e4f50 by Brandon Bay

Correcting for failed tests

Some tests failed in the previous build, mostly due to syntactic
errors. Also restored a section of code in translateMediaIndex whose
absence made a test fail.
1 parent 63c605b7
...@@ -99,7 +99,7 @@ videojs.Hls.setMediaIndexForLive = function(selectedPlaylist) { ...@@ -99,7 +99,7 @@ videojs.Hls.setMediaIndexForLive = function(selectedPlaylist) {
99 } 99 }
100 100
101 return tailIterator; 101 return tailIterator;
102 } 102 };
103 103
104 videojs.Hls.prototype.handleSourceOpen = function() { 104 videojs.Hls.prototype.handleSourceOpen = function() {
105 // construct the video data buffer and set the appropriate MIME type 105 // construct the video data buffer and set the appropriate MIME type
...@@ -795,8 +795,7 @@ videojs.Hls.getPlaylistTotalDuration = function(playlist) { ...@@ -795,8 +795,7 @@ videojs.Hls.getPlaylistTotalDuration = function(playlist) {
795 * playlist 795 * playlist
796 */ 796 */
797 videojs.Hls.translateMediaIndex = function(mediaIndex, original, update) { 797 videojs.Hls.translateMediaIndex = function(mediaIndex, original, update) {
798 var 798 var i,
799 i,
800 originalSegment, 799 originalSegment,
801 translatedMediaIndex; 800 translatedMediaIndex;
802 801
...@@ -804,14 +803,24 @@ videojs.Hls.translateMediaIndex = function(mediaIndex, original, update) { ...@@ -804,14 +803,24 @@ videojs.Hls.translateMediaIndex = function(mediaIndex, original, update) {
804 if (mediaIndex === 0) { 803 if (mediaIndex === 0) {
805 return 0; 804 return 0;
806 } 805 }
806
807 if (!(update && update.segments)) { 807 if (!(update && update.segments)) {
808 // let the media index be zero when there are no segments defined 808 // let the media index be zero when there are no segments defined
809 return 0; 809 return 0;
810 } 810 }
811 811
812 translatedMediaIndex = (mediaIndex + (original.mediaSequence - update.mediaSequence)) 812 // try to sync based on URI
813 i = update.segments.length;
814 originalSegment = original.segments[mediaIndex - 1];
815 while (i--) {
816 if (originalSegment.uri === update.segments[i].uri) {
817 return i + 1;
818 }
819 }
820
821 translatedMediaIndex = (mediaIndex + (original.mediaSequence - update.mediaSequence));
813 822
814 if (update.duration() === Infinity && translatedMediaIndex >= update.segments.length) { 823 if (update.duration === Infinity && translatedMediaIndex >= update.segments.length) {
815 // recalculate the live point if the streams are too far out of sync 824 // recalculate the live point if the streams are too far out of sync
816 return videojs.Hls.setMediaIndexForLive(update) + 1; 825 return videojs.Hls.setMediaIndexForLive(update) + 1;
817 } 826 }
......