mirror of
https://github.com/kmoskwiak/videojs-resolution-switcher.git
synced 2025-10-03 09:49:21 +02:00
Merge branch 'dev' into feature-youtube
This commit is contained in:
commit
40ea2182fb
1 changed files with 38 additions and 28 deletions
|
@ -71,6 +71,10 @@
|
||||||
if(!isPaused){
|
if(!isPaused){
|
||||||
this.player_.bigPlayButton.hide();
|
this.player_.bigPlayButton.hide();
|
||||||
}
|
}
|
||||||
|
if(typeof customSourcePicker !== 'function' &&
|
||||||
|
typeof this.options_.customSourcePicker === 'function'){
|
||||||
|
customSourcePicker = this.options_.customSourcePicker;
|
||||||
|
}
|
||||||
// Change player source and wait for loadeddata event, then play video
|
// Change player source and wait for loadeddata event, then play video
|
||||||
// loadedmetadata doesn't work right now for flash.
|
// loadedmetadata doesn't work right now for flash.
|
||||||
// Probably because of https://github.com/videojs/video-js-swf/issues/124
|
// Probably because of https://github.com/videojs/video-js-swf/issues/124
|
||||||
|
@ -102,7 +106,7 @@
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.label.innerHTML = options.initialySelectedLabel;
|
this.label.innerHTML = options.initialySelectedLabel;
|
||||||
// Sets this.player_, this.options_ and initializes the component
|
// Sets this.player_, this.options_ and initializes the component
|
||||||
MenuButton.call(this, player, options);
|
MenuButton.call(this, player, options, settings);
|
||||||
this.controlText('Quality');
|
this.controlText('Quality');
|
||||||
|
|
||||||
if(settings.dynamicLabel){
|
if(settings.dynamicLabel){
|
||||||
|
@ -129,7 +133,8 @@
|
||||||
{
|
{
|
||||||
label: key,
|
label: key,
|
||||||
src: labels[key],
|
src: labels[key],
|
||||||
initialySelected: key === this.options_.initialySelectedLabel
|
initialySelected: key === this.options_.initialySelectedLabel,
|
||||||
|
customSourcePicker: this.options_.customSourcePicker
|
||||||
},
|
},
|
||||||
onClickUnselectOthers,
|
onClickUnselectOthers,
|
||||||
this.label));
|
this.label));
|
||||||
|
@ -148,7 +153,8 @@
|
||||||
videoJsResolutionSwitcher = function(options) {
|
videoJsResolutionSwitcher = function(options) {
|
||||||
var settings = videojs.mergeOptions(defaults, options),
|
var settings = videojs.mergeOptions(defaults, options),
|
||||||
player = this,
|
player = this,
|
||||||
label = document.createElement('span');
|
label = document.createElement('span'),
|
||||||
|
groupedSrc = {};
|
||||||
|
|
||||||
label.classList.add('vjs-resolution-button-label');
|
label.classList.add('vjs-resolution-button-label');
|
||||||
|
|
||||||
|
@ -167,9 +173,9 @@
|
||||||
}
|
}
|
||||||
//Sort sources
|
//Sort sources
|
||||||
src = src.sort(compareResolutions);
|
src = src.sort(compareResolutions);
|
||||||
var groupedSrc = bucketSources(src);
|
groupedSrc = bucketSources(src);
|
||||||
var choosen = chooseSrc(groupedSrc, src);
|
var choosen = chooseSrc(groupedSrc, src);
|
||||||
var menuButton = new ResolutionMenuButton(player, { sources: groupedSrc, initialySelectedLabel: choosen.label , initialySelectedRes: choosen.res }, settings, label);
|
var menuButton = new ResolutionMenuButton(player, { sources: groupedSrc, initialySelectedLabel: choosen.label , initialySelectedRes: choosen.res , customSourcePicker: settings.customSourcePicker}, settings, label);
|
||||||
menuButton.el().classList.add('vjs-resolution-button');
|
menuButton.el().classList.add('vjs-resolution-button');
|
||||||
player.controlBar.resolutionSwitcher = player.controlBar.addChild(menuButton);
|
player.controlBar.resolutionSwitcher = player.controlBar.addChild(menuButton);
|
||||||
return setSourcesSanitized(player, choosen.sources, choosen.label);
|
return setSourcesSanitized(player, choosen.sources, choosen.label);
|
||||||
|
@ -189,6 +195,10 @@
|
||||||
return player;
|
return player;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
player.getGroupedSrc = function(){
|
||||||
|
return groupedSrc;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method used for sorting list of sources
|
* Method used for sorting list of sources
|
||||||
* @param {Object} a - source object with res property
|
* @param {Object} a - source object with res property
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue