From e7bba46933e5b503e380c572d0c4322b246ad0fa Mon Sep 17 00:00:00 2001 From: Kevin Stubbs Date: Mon, 16 Oct 2017 11:42:25 -0700 Subject: [PATCH 1/3] Sort sources by resolution. Fix typo. --- lib/videojs-resolution-switcher.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/videojs-resolution-switcher.js b/lib/videojs-resolution-switcher.js index 73ea7f1..747460a 100644 --- a/lib/videojs-resolution-switcher.js +++ b/lib/videojs-resolution-switcher.js @@ -352,10 +352,12 @@ }); player.one('loadedmetadata', function(){ - var playlists = hls.playlists.master.playlists; - + var playlists = hls.playlists.master.playlists.sort(function (a, b) { + return b.attributes.RESOLUTION.height - a.attributes.RESOLUTION.height; + }); + var _sources = [{ src: 'auto', type: 'application/x-mpegURL', label: 'auto', res: 'auto'}]; - + playlists.map(function(value){ _sources.push({ src: value.uri, @@ -383,7 +385,7 @@ return _selectPlaylist; }; - // Overwrite defualt sourcePicer function + // Overwrite defualt sourcePicker function var _customSourcePicker = function(_player, _sources, _label){ var selectedRes = _sources[0].res; hls.selectPlaylist = selectPlaylist(selectedRes); @@ -432,4 +434,4 @@ // register the plugin videojs.plugin('videoJsResolutionSwitcher', videoJsResolutionSwitcher); })(window, videojs); -})(); +})(); \ No newline at end of file From 5acb5aca51e0f5b01212f54e987a5ece6e39cf4f Mon Sep 17 00:00:00 2001 From: Kevin Stubbs Date: Mon, 16 Oct 2017 11:43:40 -0700 Subject: [PATCH 2/3] Revert some accidental changes. --- lib/videojs-resolution-switcher.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/videojs-resolution-switcher.js b/lib/videojs-resolution-switcher.js index 747460a..3d70177 100644 --- a/lib/videojs-resolution-switcher.js +++ b/lib/videojs-resolution-switcher.js @@ -357,7 +357,7 @@ }); var _sources = [{ src: 'auto', type: 'application/x-mpegURL', label: 'auto', res: 'auto'}]; - + playlists.map(function(value){ _sources.push({ src: value.uri, @@ -434,4 +434,4 @@ // register the plugin videojs.plugin('videoJsResolutionSwitcher', videoJsResolutionSwitcher); })(window, videojs); -})(); \ No newline at end of file +})(); From f9e3502cafe2851c84add9b5eab041fc968052ef Mon Sep 17 00:00:00 2001 From: Kevin Stubbs Date: Mon, 16 Oct 2017 11:45:32 -0700 Subject: [PATCH 3/3] Fix more typos. --- lib/videojs-resolution-switcher.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/videojs-resolution-switcher.js b/lib/videojs-resolution-switcher.js index 3d70177..65e5f91 100644 --- a/lib/videojs-resolution-switcher.js +++ b/lib/videojs-resolution-switcher.js @@ -324,7 +324,7 @@ groupedSrc = bucketSources(_sources); - // Overwrite defualt sourcePicer function + // Overwrite default sourcePicker function var _customSourcePicker = function(_player, _sources, _label){ player.tech_.ytPlayer.setPlaybackQuality(_sources[0]._yt); return player; @@ -385,7 +385,7 @@ return _selectPlaylist; }; - // Overwrite defualt sourcePicker function + // Overwrite default sourcePicker function var _customSourcePicker = function(_player, _sources, _label){ var selectedRes = _sources[0].res; hls.selectPlaylist = selectPlaylist(selectedRes);