mirror of
https://github.com/kmoskwiak/videojs-resolution-switcher.git
synced 2025-10-03 09:49:21 +02:00
get current resolution method
This commit is contained in:
parent
535264d165
commit
1cbbd10577
1 changed files with 19 additions and 6 deletions
|
@ -18,9 +18,14 @@
|
||||||
|
|
||||||
|
|
||||||
var defaults = {},
|
var defaults = {},
|
||||||
videoJsResolutionSwitcher;
|
videoJsResolutionSwitcher,
|
||||||
|
currentResolution = {};
|
||||||
|
|
||||||
function setSourcesSanitized(player, sources) {
|
function setSourcesSanitized(player, sources, label) {
|
||||||
|
currentResolution = {
|
||||||
|
label: label,
|
||||||
|
sources: sources
|
||||||
|
};
|
||||||
return player.src(sources.map(function(src) {
|
return player.src(sources.map(function(src) {
|
||||||
return {src: src.src, type: src.type, res: src.res};
|
return {src: src.src, type: src.type, res: src.res};
|
||||||
}));
|
}));
|
||||||
|
@ -65,7 +70,7 @@
|
||||||
// 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
|
||||||
setSourcesSanitized(this.player_, this.src).one('loadeddata', function() {
|
setSourcesSanitized(this.player_, this.src, this.label).one('loadeddata', function() {
|
||||||
this.player_.currentTime(currentTime);
|
this.player_.currentTime(currentTime);
|
||||||
this.player_.handleTechSeeked_();
|
this.player_.handleTechSeeked_();
|
||||||
if(!isPaused){
|
if(!isPaused){
|
||||||
|
@ -151,7 +156,15 @@
|
||||||
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 }, 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);
|
return setSourcesSanitized(player, choosen.sources, choosen.label);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns current resolution
|
||||||
|
* @returns {Object} current resolution object {label: '', sources: []}
|
||||||
|
*/
|
||||||
|
player.currentResolution = function(){
|
||||||
|
return currentResolution;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue