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,EAAO,SAAW,SAAU,GAE3B,OAAO,CACR,GAID,EAAO,cAAgB,WAEtB,QAAkC,IAAtB,EAAO,WAElB,OAAO,EAAO,WAId,IAEC,OAAO,IAAM,EAAO,UAAU,QAAQ,GAAG,WAE1C,CAAE,MAAM,GAEP,MAAO,EACR,CAEF,EAGA,EAAO,UAAY,SAAU,GAE5B,IAGC,EACA,EAJG,EAAW,EAAO,KAAK,WAC1B,EAAY,EAAO,SACnB,EAAe,EAAO,cAKvB,GAAK,EAAO,iBAAmB,GACzB,EAAO,cACP,EAAO,aAAa,GAF1B,CAsBA,GAjBK,QAAU,EAAS,UAAY,EAAS,QAAU,YAGvD,EAAO,IAAK,EAAO,aAAa,IAAqB,IAAK,kBAAkB,WAE3E,EAAO,YAAa,GAGpB,EAAO,SAAU,mBAEV,GAAc,EAAO,MAC7B,IAGA,EAAO,WAAa,EAGf,EAAO,WAAW,mBAMtB,IAHA,GADA,EAAe,EAAO,WAAW,mBAAmB,KAAK,WAAW,UACnC,OAGzB,EAAoB,GAI3B,GAAK,oBAAsB,IAF3B,GAE2D,UAAY,CAEtE,EAAa,GAAmB,UAAY,EAAmB,GAC/D,KACD,CAKF,EAAO,QAAS,YAvCyC,CAwC1D,GAOA,EAAc,EAAO,mBAEA,EAAc,EAAmB,IAGtD,EAAqB,IAAI,EAAI,mBAAoB,EAAQ,CACxD,WAAc,EAAO,SAAU,GAAe,WAC9C,cAAgB,IAIjB,EAAO,WAAW,mBAAqB,EAAO,WAAW,SAAU,EArHzB,CAxFW,CA8MtD,GAEA,CAtXD,CAsXI","file":"/npm/videojs-resolution-selector@1.6.2/video-quality-selector.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/videojs-resolution-selector@1.6.2/video-quality-selector.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\r\n * Video.js Resolution Selector\r\n *\r\n * This plugin for Video.js adds a resolution selector option\r\n * to the toolbar. Usage:\r\n *\r\n * <video>\r\n * \t<source data-res=\"480\" src=\"...\" />\r\n * \t<source data-res=\"240\" src=\"...\" />\r\n * </video>\r\n */\r\n\r\n(function( _V_ ) {\r\n\t\r\n\t/***********************************************************************************\r\n\t * Define some helper functions\r\n\t ***********************************************************************************/\r\n\tvar methods = {\r\n\t\t\r\n\t\t/**\r\n\t\t * In a future version, this can be made more intelligent,\r\n\t\t * but for now, we'll just add a \"p\" at the end if we are passed\r\n\t\t * numbers.\r\n\t\t *\r\n\t\t * @param\t(string)\tres\tThe resolution to make a label for\r\n\t\t *\r\n\t\t * @returns\t(string)\tThe label text string\r\n\t\t */\r\n\t\tres_label : function( res ) {\r\n\t\t\t\r\n\t\t\treturn ( /^\\d+$/.test( res ) ) ? res + 'p' : res;\r\n\t\t}\r\n\t};\r\n\t\r\n\t/***********************************************************************************\r\n\t * Setup our resolution menu items\r\n\t ***********************************************************************************/\r\n\t_V_.ResolutionMenuItem = _V_.MenuItem.extend({\r\n\t\t\r\n\t\t// Call variable to prevent the resolution change from being called twice\r\n\t\tcall_count : 0,\r\n\t\t\r\n\t\t/** @constructor */\r\n\t\tinit : function( player, options ){\r\n\t\t\t\r\n\t\t\tvar touchstart = false;\r\n\t\t\t\r\n\t\t\t// Modify options for parent MenuItem class's init.\r\n\t\t\toptions.label = methods.res_label( options.res );\r\n\t\t\toptions.selected = ( options.res.toString() === player.getCurrentRes().toString() );\r\n\t\t\t\r\n\t\t\t// Call the parent constructor\r\n\t\t\t_V_.MenuItem.call( this, player, options );\r\n\t\t\t\r\n\t\t\t// Store the resolution as a property\r\n\t\t\tthis.resolution = options.res;\r\n\t\t\t\r\n\t\t\t// Register our click and tap handlers\r\n\t\t\tthis.on( ['click', 'tap'], this.onClick );\r\n\t\t\t\r\n\t\t\t// Toggle the selected class whenever the resolution changes\r\n\t\t\tplayer.on( 'changeRes', _V_.bind( this, function() {\r\n\t\t\t\t\r\n\t\t\t\tif ( this.resolution == player.getCurrentRes() ) {\r\n\t\t\t\t\t\r\n\t\t\t\t\tthis.selected( true );\r\n\t\t\t\t\t\r\n\t\t\t\t} else {\r\n\t\t\t\t\t\r\n\t\t\t\t\tthis.selected( false );\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t// Reset the call count\r\n\t\t\t\tthis.call_count = 0;\r\n\t\t\t}));\r\n\t\t}\r\n\t});\r\n\t\r\n\t// Handle clicks on the menu items\r\n\t_V_.ResolutionMenuItem.prototype.onClick = function() {\r\n\t\t\r\n\t\t// Check if this has already been called\r\n\t\tif ( this.call_count > 0 ) { return; }\r\n\t\t\r\n\t\t// Call the player.changeRes method\r\n\t\tthis.player().changeRes( this.resolution );\r\n\t\t\r\n\t\t// Increment the call counter\r\n\t\tthis.call_count++;\r\n\t};\r\n\t\r\n\t/***********************************************************************************\r\n\t * Setup our resolution menu title item\r\n\t ***********************************************************************************/\r\n\t_V_.ResolutionTitleMenuItem = _V_.MenuItem.extend({\r\n\t\t\r\n\t\tinit : function( player, options ) {\r\n\t\t\t\r\n\t\t\t// Call the parent constructor\r\n\t\t\t_V_.MenuItem.call( this, player, options );\r\n\t\t\t\r\n\t\t\t// No click handler for the menu title\r\n\t\t\tthis.off( 'click' );\r\n\t\t}\r\n\t});\r\n\t\r\n\t/***********************************************************************************\r\n\t * Define our resolution selector button\r\n\t ***********************************************************************************/\r\n\t_V_.ResolutionSelector = _V_.MenuButton.extend({\r\n\t\t\r\n\t\t/** @constructor */\r\n\t\tinit : function( player, options ) {\r\n\t\t\t\r\n\t\t\t// Add our list of available resolutions to the player object\r\n\t\t\tplayer.availableRes = options.available_res;\r\n\t\t\t\r\n\t\t\t// Call the parent constructor\r\n\t\t\t_V_.MenuButton.call( this, player, options );\r\n\t\t\t\r\n\t\t\t// Set the button text based on the option provided\r\n\t\t\tthis.el().firstChild.firstChild.innerHTML = options.buttonText;\r\n\t\t}\r\n\t});\r\n\t\r\n\t// Set class for resolution selector button\r\n\t_V_.ResolutionSelector.prototype.className = 'vjs-res-button';\r\n\t\r\n\t// Create a menu item for each available resolution\r\n\t_V_.ResolutionSelector.prototype.createItems = function() {\r\n\t\t\r\n\t\tvar player = this.player(),\r\n\t\t\titems = [],\r\n\t\t\tcurrent_res;\r\n\t\t\r\n\t\t// Add the menu title item\r\n\t\titems.push( new _V_.ResolutionTitleMenuItem( player, {\r\n\t\t\t\r\n\t\t\tel : _V_.Component.prototype.createEl( 'li', {\r\n\t\t\t\t\r\n\t\t\t\tclassName\t: 'vjs-menu-title vjs-res-menu-title',\r\n\t\t\t\tinnerHTML\t: player.localize( 'Quality' )\r\n\t\t\t})\r\n\t\t}));\r\n\t\t\r\n\t\t// Add an item for each available resolution\r\n\t\tfor ( current_res in player.availableRes ) {\r\n\t\t\t\r\n\t\t\t// Don't add an item for the length attribute\r\n\t\t\tif ( 'length' == current_res ) { continue; }\r\n\t\t\t\r\n\t\t\titems.push( new _V_.ResolutionMenuItem( player, {\r\n\t\t\t\tres : current_res\r\n\t\t\t}));\r\n\t\t}\r\n\t\t\r\n\t\t// Sort the available resolutions in descending order\r\n\t\titems.sort(function( a, b ) {\r\n\t\t\t\r\n\t\t\tif ( typeof a.resolution == 'undefined' ) {\r\n\t\t\t\t\r\n\t\t\t\treturn -1;\r\n\t\t\t\t\r\n\t\t\t} else {\r\n\t\t\t\t\r\n\t\t\t\treturn parseInt( b.resolution ) - parseInt( a.resolution );\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t\treturn items;\r\n\t};\r\n\t\r\n\t/***********************************************************************************\r\n\t * Register the plugin with videojs, main plugin function\r\n\t ***********************************************************************************/\r\n\t_V_.plugin( 'resolutionSelector', function( options ) {\r\n\t\t\r\n\t\t// Only enable the plugin on HTML5 videos\r\n\t\tif ( ! this.el().firstChild.canPlayType  ) { return; }\t\r\n\t\t\r\n\t\t/*******************************************************************\r\n\t\t * Setup variables, parse settings\r\n\t\t *******************************************************************/\r\n\t\tvar player = this,\r\n\t\t\tsources\t= player.options().sources,\r\n\t\t\ti = sources.length,\r\n\t\t\tj,\r\n\t\t\tfound_type,\r\n\t\t\t\r\n\t\t\t// Override default options with those provided\r\n\t\t\tsettings = _V_.util.mergeOptions({\r\n\t\t\t\t\r\n\t\t\t\tdefault_res\t: '',\t\t// (string)\tThe resolution that should be selected by default ( '480' or  '480,1080,240' )\r\n\t\t\t\tforce_types\t: false\t\t// (array)\tList of media types. If passed, we need to have source for each type in each resolution or that resolution will not be an option\r\n\t\t\t\t\r\n\t\t\t}, options || {} ),\r\n\t\t\t\r\n\t\t\tavailable_res = { length : 0 },\r\n\t\t\tcurrent_res,\r\n\t\t\tresolutionSelector,\r\n\t\t\t\r\n\t\t\t// Split default resolutions if set and valid, otherwise default to an empty array\r\n\t\t\tdefault_resolutions = ( settings.default_res && typeof settings.default_res == 'string' ) ? settings.default_res.split( ',' ) : [];\r\n\t\t\r\n\t\t// Get all of the available resoloutions\r\n\t\twhile ( i > 0 ) {\r\n\t\t\t\r\n\t\t\ti--;\r\n\t\t\t\r\n\t\t\t// Skip sources that don't have data-res attributes\r\n\t\t\tif ( ! sources[i]['data-res'] ) { continue; }\r\n\t\t\t\r\n\t\t\tcurrent_res = sources[i]['data-res'];\r\n\t\t\t\r\n\t\t\tif ( typeof available_res[current_res] !== 'object' ) {\r\n\t\t\t\t\r\n\t\t\t\tavailable_res[current_res] = [];\r\n\t\t\t\tavailable_res.length++;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tavailable_res[current_res].unshift( sources[i] );\r\n\t\t}\r\n\t\t\r\n\t\t// Check for forced types\r\n\t\tif ( settings.force_types ) {\r\n\t\t\t\r\n\t\t\t// Loop through all available resoultions\r\n\t\t\tfor ( current_res in available_res ) {\r\n\t\t\t\t\r\n\t\t\t\t// Don't count the length property as a resolution\r\n\t\t\t\tif ( 'length' == current_res ) { continue; }\r\n\t\t\t\t\r\n\t\t\t\ti = settings.force_types.length;\r\n\t\t\t\tfound_types = 0;\r\n\t\t\t\t\r\n\t\t\t\t// Loop through all required types\r\n\t\t\t\twhile ( i > 0 ) {\r\n\t\t\t\t\t\r\n\t\t\t\t\ti--;\r\n\t\t\t\t\t\r\n\t\t\t\t\tj = available_res[current_res].length;\r\n\t\t\t\t\t\r\n\t\t\t\t\t// Loop through all available sources in current resolution\r\n\t\t\t\t\twhile ( j > 0 ) {\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tj--;\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t// Check if the current source matches the current type we're checking\r\n\t\t\t\t\t\tif ( settings.force_types[i] === available_res[current_res][j].type ) {\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tfound_types++;\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t// If we didn't find sources for all of the required types in the current res, remove it\r\n\t\t\t\tif ( found_types < settings.force_types.length ) {\r\n\t\t\t\t\t\r\n\t\t\t\t\tdelete available_res[current_res];\r\n\t\t\t\t\tavailable_res.length--;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t// Make sure we have at least 2 available resolutions before we add the button\r\n\t\tif ( available_res.length < 2 ) { return; }\r\n\t\t\r\n\t\t// Loop through the choosen default resolutions if there were any\r\n\t\tfor ( i = 0; i < default_resolutions.length; i++ ) {\r\n\t\t\t\r\n\t\t\t// Set the video to start out with the first available default res\r\n\t\t\tif ( available_res[default_resolutions[i]] ) {\r\n\t\t\t\t\r\n\t\t\t\tplayer.src( available_res[default_resolutions[i]] );\r\n\t\t\t\tplayer.currentRes = default_resolutions[i];\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t/*******************************************************************\r\n\t\t * Add methods to player object\r\n\t\t *******************************************************************/\r\n\t\t\r\n\t\t// Make sure we have player.localize() if it's not defined by Video.js\r\n\t\tif ( typeof player.localize !== 'function' ) {\r\n\t\t\t\r\n\t\t\tplayer.localize = function( string ) {\r\n\t\t\t\t\r\n\t\t\t\treturn string;\r\n\t\t\t};\r\n\t\t}\r\n\t\t\r\n\t\t// Helper function to get the current resolution\r\n\t\tplayer.getCurrentRes = function() {\r\n\t\t\t\r\n\t\t\tif ( typeof player.currentRes !== 'undefined' ) {\r\n\t\t\t\t\r\n\t\t\t\treturn player.currentRes;\r\n\t\t\t\t\r\n\t\t\t} else {\r\n\t\t\t\t\r\n\t\t\t\ttry {\r\n\t\t\t\t\t\r\n\t\t\t\t\treturn res = player.options().sources[0]['data-res'];\r\n\t\t\t\t\t\r\n\t\t\t\t} catch(e) {\r\n\t\t\t\t\t\r\n\t\t\t\t\treturn '';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\t// Define the change res method\r\n\t\tplayer.changeRes = function( target_resolution ) {\r\n\t\t\t\r\n\t\t\tvar video_el = player.el().firstChild,\r\n\t\t\t\tis_paused = player.paused(),\r\n\t\t\t\tcurrent_time = player.currentTime(),\r\n\t\t\t\tbutton_nodes,\r\n\t\t\t\tbutton_node_count;\r\n\t\t\t\r\n\t\t\t// Do nothing if we aren't changing resolutions or if the resolution isn't defined\r\n\t\t\tif ( player.getCurrentRes() == target_resolution\r\n\t\t\t\t|| ! player.availableRes\r\n\t\t\t\t|| ! player.availableRes[target_resolution] ) { return; }\r\n\t\t\t\r\n\t\t\t// Make sure the loadedmetadata event will fire\r\n\t\t\tif ( 'none' == video_el.preload ) { video_el.preload = 'metadata'; }\r\n\t\t\t\r\n\t\t\t// Change the source and make sure we don't start the video over\t\t\r\n\t\t\tplayer.src( player.availableRes[target_resolution] ).one( 'loadedmetadata', function() {\r\n\t\t\t\t\r\n\t\t\t\tplayer.currentTime( current_time );\r\n\t\t\t\t\r\n\t\t\t\t// If the video was paused, don't show the poster image again\r\n\t\t\t\tplayer.addClass( 'vjs-has-started' );\r\n\t\t\t\t\r\n\t\t\t\tif ( ! is_paused ) { player.play(); }\r\n\t\t\t});\r\n\t\t\t\r\n\t\t\t// Save the newly selected resolution in our player options property\r\n\t\t\tplayer.currentRes = target_resolution;\r\n\t\t\t\r\n\t\t\t// Make sure the button has been added to the control bar\r\n\t\t\tif ( player.controlBar.resolutionSelector ) {\r\n\t\t\t\t\r\n\t\t\t\tbutton_nodes = player.controlBar.resolutionSelector.el().firstChild.children;\r\n\t\t\t\tbutton_node_count = button_nodes.length;\r\n\t\t\t\t\r\n\t\t\t\t// Update the button text\r\n\t\t\t\twhile ( button_node_count > 0 ) {\r\n\t\t\t\t\t\r\n\t\t\t\t\tbutton_node_count--;\r\n\t\t\t\t\t\r\n\t\t\t\t\tif ( 'vjs-control-text' == button_nodes[button_node_count].className ) {\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tbutton_nodes[button_node_count].innerHTML = methods.res_label( target_resolution );\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// Update the classes to reflect the currently selected resolution\r\n\t\t\tplayer.trigger( 'changeRes' );\r\n\t\t};\r\n\t\t\r\n\t\t/*******************************************************************\r\n\t\t * Add the resolution selector button\r\n\t\t *******************************************************************/\r\n\t\t\r\n\t\t// Get the starting resolution\r\n\t\tcurrent_res = player.getCurrentRes();\r\n\t\t\r\n\t\tif ( current_res ) { current_res = methods.res_label( current_res ); }\r\n\t\t\r\n\t\t// Add the resolution selector button\r\n\t\tresolutionSelector = new _V_.ResolutionSelector( player, {\r\n\t\t\tbuttonText\t\t: player.localize( current_res || 'Quality' ),\r\n\t\t\tavailable_res\t: available_res\r\n\t\t});\r\n\t\t\r\n\t\t// Add the button to the control bar object and the DOM\r\n\t\tplayer.controlBar.resolutionSelector = player.controlBar.addChild( resolutionSelector );\r\n\t});\r\n\r\n})( videojs );"]}