a5ab53ec by David LaPalomento Committed by brandonocasey

Style fixes and restoring some command ordering

The refactor should not have changed the required ordering for statements so restore it. Adjust styles a tad.
1 parent 99580d5c
...@@ -91,7 +91,7 @@ Hls.findSoleUncommonTimeRangesEnd_ = function(original, update) { ...@@ -91,7 +91,7 @@ Hls.findSoleUncommonTimeRangesEnd_ = function(original, update) {
91 /** 91 /**
92 * Whether the browser has built-in HLS support. 92 * Whether the browser has built-in HLS support.
93 */ 93 */
94 Hls.supportsNativeHls = function() { 94 Hls.supportsNativeHls = (function() {
95 let video = document.createElement('video'); 95 let video = document.createElement('video');
96 let xMpegUrl; 96 let xMpegUrl;
97 let vndMpeg; 97 let vndMpeg;
...@@ -105,7 +105,7 @@ Hls.supportsNativeHls = function() { ...@@ -105,7 +105,7 @@ Hls.supportsNativeHls = function() {
105 vndMpeg = video.canPlayType('application/vnd.apple.mpegURL'); 105 vndMpeg = video.canPlayType('application/vnd.apple.mpegURL');
106 return (/probably|maybe/).test(xMpegUrl) || 106 return (/probably|maybe/).test(xMpegUrl) ||
107 (/probably|maybe/).test(vndMpeg); 107 (/probably|maybe/).test(vndMpeg);
108 }; 108 }());
109 109
110 // HLS is a source handler, not a tech. Make sure attempts to use it 110 // HLS is a source handler, not a tech. Make sure attempts to use it
111 // as one do not cause exceptions. 111 // as one do not cause exceptions.
...@@ -717,6 +717,7 @@ export default class HlsHandler extends Component { ...@@ -717,6 +717,7 @@ export default class HlsHandler extends Component {
717 let variant; 717 let variant;
718 let bandwidthBestVariant; 718 let bandwidthBestVariant;
719 let resolutionPlusOne; 719 let resolutionPlusOne;
720 let resolutionPlusOneAttribute;
720 let resolutionBestVariant; 721 let resolutionBestVariant;
721 let width; 722 let width;
722 let height; 723 let height;
...@@ -725,9 +726,9 @@ export default class HlsHandler extends Component { ...@@ -725,9 +726,9 @@ export default class HlsHandler extends Component {
725 726
726 // filter out any playlists that have been excluded due to 727 // filter out any playlists that have been excluded due to
727 // incompatible configurations or playback errors 728 // incompatible configurations or playback errors
728 sortedPlaylists = sortedPlaylists.filter((localvariant) => { 729 sortedPlaylists = sortedPlaylists.filter((localVariant) => {
729 if (typeof localvariant.excludeUntil !== 'undefined') { 730 if (typeof localVariant.excludeUntil !== 'undefined') {
730 return now >= localvariant.excludeUntil; 731 return now >= localVariant.excludeUntil;
731 } 732 }
732 return true; 733 return true;
733 }); 734 });
...@@ -785,21 +786,22 @@ export default class HlsHandler extends Component { ...@@ -785,21 +786,22 @@ export default class HlsHandler extends Component {
785 // since the playlists are sorted, the first variant that has 786 // since the playlists are sorted, the first variant that has
786 // dimensions less than or equal to the player size is the best 787 // dimensions less than or equal to the player size is the best
787 788
788 if (variant.attributes.RESOLUTION.width === width && 789 let variantResolution = variant.attributes.RESOLUTION;
789 variant.attributes.RESOLUTION.height === height) { 790
791 if (variantResolution.width === width &&
792 variantResolution.height === height) {
790 // if we have the exact resolution as the player use it 793 // if we have the exact resolution as the player use it
791 resolutionPlusOne = null; 794 resolutionPlusOne = null;
792 resolutionBestVariant = variant; 795 resolutionBestVariant = variant;
793 break; 796 break;
794 } else if (variant.attributes.RESOLUTION.width < width && 797 } else if (variantResolution.width < width &&
795 variant.attributes.RESOLUTION.height < height) { 798 variantResolution.height < height) {
796 // if both dimensions are less than the player use the 799 // if both dimensions are less than the player use the
797 // previous (next-largest) variant 800 // previous (next-largest) variant
798 break; 801 break;
799 } else if (!resolutionPlusOne || (variant.attributes.RESOLUTION.width < 802 } else if (!resolutionPlusOne ||
800 resolutionPlusOne.attributes.RESOLUTION.width && 803 (variantResolution.width < resolutionPlusOneAttribute.width &&
801 variant.attributes.RESOLUTION.height < 804 variantResolution.height < resolutionPlusOneAttribute.height)) {
802 resolutionPlusOne.attributes.RESOLUTION.height)) {
803 // If we still haven't found a good match keep a 805 // If we still haven't found a good match keep a
804 // reference to the previous variant for the next loop 806 // reference to the previous variant for the next loop
805 // iteration 807 // iteration
...@@ -809,6 +811,7 @@ export default class HlsHandler extends Component { ...@@ -809,6 +811,7 @@ export default class HlsHandler extends Component {
809 // the highest bandwidth variant that is just-larger-than 811 // the highest bandwidth variant that is just-larger-than
810 // the video player 812 // the video player
811 resolutionPlusOne = variant; 813 resolutionPlusOne = variant;
814 resolutionPlusOneAttribute = resolutionPlusOneAttribute.attributes.RESOLUTION;
812 } 815 }
813 } 816 }
814 817
...@@ -930,12 +933,13 @@ export default class HlsHandler extends Component { ...@@ -930,12 +933,13 @@ export default class HlsHandler extends Component {
930 933
931 // we have entered a state where we are fetching the same segment, 934 // we have entered a state where we are fetching the same segment,
932 // try to walk forward 935 // try to walk forward
936 /* eslint-disable max-len */
933 if (this.lastSegmentLoaded_ && 937 if (this.lastSegmentLoaded_ &&
934 this.playlistUriToUrl(this.lastSegmentLoaded_.uri) === 938 this.playlistUriToUrl(this.lastSegmentLoaded_.uri) === this.playlistUriToUrl(segment.uri) &&
935 this.playlistUriToUrl(segment.uri) &&
936 this.lastSegmentLoaded_.byterange === segment.byterange) { 939 this.lastSegmentLoaded_.byterange === segment.byterange) {
937 return this.fillBuffer(mediaIndex + 1); 940 return this.fillBuffer(mediaIndex + 1);
938 } 941 }
942 /* eslint-enable max-len */
939 943
940 // package up all the work to append the segment 944 // package up all the work to append the segment
941 segmentInfo = { 945 segmentInfo = {
...@@ -1236,9 +1240,9 @@ export default class HlsHandler extends Component { ...@@ -1236,9 +1240,9 @@ export default class HlsHandler extends Component {
1236 decrypter = new Hls.Decrypter(segmentInfo.encryptedBytes, 1240 decrypter = new Hls.Decrypter(segmentInfo.encryptedBytes,
1237 segment.key.bytes, 1241 segment.key.bytes,
1238 segIv, 1242 segIv,
1239 function(err, localBytes) { 1243 function(error, localBytes) {
1240 if (err) { 1244 if (error) {
1241 throw new Error(err); 1245 videojs.log.warn(error);
1242 } 1246 }
1243 segmentInfo.bytes = localBytes; 1247 segmentInfo.bytes = localBytes;
1244 }); 1248 });
...@@ -1415,10 +1419,10 @@ export default class HlsHandler extends Component { ...@@ -1415,10 +1419,10 @@ export default class HlsHandler extends Component {
1415 * @return a new TimeRanges object. 1419 * @return a new TimeRanges object.
1416 */ 1420 */
1417 HlsHandler.prototype.findBufferedRange_ = 1421 HlsHandler.prototype.findBufferedRange_ =
1418 filterBufferedRanges(function(start, end, time) { 1422 filterBufferedRanges(function(start, end, time) {
1419 return start - TIME_FUDGE_FACTOR <= time && 1423 return start - TIME_FUDGE_FACTOR <= time &&
1420 end + TIME_FUDGE_FACTOR >= time; 1424 end + TIME_FUDGE_FACTOR >= time;
1421 }); 1425 });
1422 /** 1426 /**
1423 * Returns the TimeRanges that begin at or later than the specified 1427 * Returns the TimeRanges that begin at or later than the specified
1424 * time. 1428 * time.
...@@ -1427,9 +1431,9 @@ filterBufferedRanges(function(start, end, time) { ...@@ -1427,9 +1431,9 @@ filterBufferedRanges(function(start, end, time) {
1427 * @return a new TimeRanges object. 1431 * @return a new TimeRanges object.
1428 */ 1432 */
1429 HlsHandler.prototype.findNextBufferedRange_ = 1433 HlsHandler.prototype.findNextBufferedRange_ =
1430 filterBufferedRanges(function(start, end, time) { 1434 filterBufferedRanges(function(start, end, time) {
1431 return start - TIME_FUDGE_FACTOR >= time; 1435 return start - TIME_FUDGE_FACTOR >= time;
1432 }); 1436 });
1433 1437
1434 /** 1438 /**
1435 * The Source Handler object, which informs video.js what additional 1439 * The Source Handler object, which informs video.js what additional
...@@ -1468,7 +1472,7 @@ HlsSourceHandler.canPlayType = function(type) { ...@@ -1468,7 +1472,7 @@ HlsSourceHandler.canPlayType = function(type) {
1468 let mpegurlRE = /^application\/(?:x-|vnd\.apple\.)mpegurl/i; 1472 let mpegurlRE = /^application\/(?:x-|vnd\.apple\.)mpegurl/i;
1469 1473
1470 // favor native HLS support if it's available 1474 // favor native HLS support if it's available
1471 if (Hls.supportsNativeHls()) { 1475 if (Hls.supportsNativeHls) {
1472 return false; 1476 return false;
1473 } 1477 }
1474 return mpegurlRE.test(type); 1478 return mpegurlRE.test(type);
......