mirror of
https://github.com/kmoskwiak/videojs-resolution-switcher.git
synced 2025-10-04 10:19:21 +02:00
More changes to videojs 7
- Make resolution hover - changed to handleTechSeeked_ - force resolution switch to change label
This commit is contained in:
parent
dfc6b0e389
commit
9c23135d3b
1 changed files with 19 additions and 7 deletions
|
@ -31,16 +31,20 @@
|
||||||
MenuItem.call(this, player, options);
|
MenuItem.call(this, player, options);
|
||||||
this.src = options.src;
|
this.src = options.src;
|
||||||
|
|
||||||
player.on('resolutionchange', videojs.bind(this, this.update));
|
player.on('resolutionchange', videojs.bind(this, this.update))
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
ResolutionMenuItem.prototype.handleClick = function(event){
|
ResolutionMenuItem.prototype.handleClick = function(event){
|
||||||
MenuItem.prototype.handleClick.call(this,event);
|
MenuItem.prototype.handleClick.call(this, event);
|
||||||
this.player_.currentResolution(this.options_.label);
|
this.player_.currentResolution(this.options_.label);
|
||||||
|
// this.player_.updateSrc(this.player_.options_.sources)
|
||||||
|
// MenuButton.prototype.update.call(this);
|
||||||
};
|
};
|
||||||
ResolutionMenuItem.prototype.update = function(){
|
ResolutionMenuItem.prototype.update = function(){
|
||||||
var selection = this.player_.currentResolution();
|
var selection = (this.player_ && this.player_.currentResolution() ) ? this.player_.currentResolution() : null ;
|
||||||
|
if ( selection ) {
|
||||||
this.selected(this.options_.label === selection.label);
|
this.selected(this.options_.label === selection.label);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
MenuItem.registerComponent('ResolutionMenuItem', ResolutionMenuItem);
|
MenuItem.registerComponent('ResolutionMenuItem', ResolutionMenuItem);
|
||||||
|
|
||||||
|
@ -56,7 +60,6 @@
|
||||||
MenuButton.call(this, player, options);
|
MenuButton.call(this, player, options);
|
||||||
this.el().setAttribute('aria-label','Quality');
|
this.el().setAttribute('aria-label','Quality');
|
||||||
this.controlText('Quality');
|
this.controlText('Quality');
|
||||||
|
|
||||||
if(options.dynamicLabel){
|
if(options.dynamicLabel){
|
||||||
videojs.dom.addClass(this.label, 'vjs-resolution-button-label');
|
videojs.dom.addClass(this.label, 'vjs-resolution-button-label');
|
||||||
this.el().appendChild(this.label);
|
this.el().appendChild(this.label);
|
||||||
|
@ -65,6 +68,14 @@
|
||||||
videojs.dom.addClass(staticLabel, 'vjs-menu-icon');
|
videojs.dom.addClass(staticLabel, 'vjs-menu-icon');
|
||||||
this.el().appendChild(staticLabel);
|
this.el().appendChild(staticLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make hover on resolution button
|
||||||
|
this.el().addEventListener('mouseover', function(e) {
|
||||||
|
videojs.dom.addClass(this, 'vjs-hover');
|
||||||
|
});
|
||||||
|
|
||||||
|
// force update of resolution to change label
|
||||||
|
player.on('resolutionchange', videojs.bind(this, this.update))
|
||||||
player.on('updateSources', videojs.bind( this, this.update ) );
|
player.on('updateSources', videojs.bind( this, this.update ) );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
@ -94,6 +105,7 @@
|
||||||
return MenuButton.prototype.update.call(this);
|
return MenuButton.prototype.update.call(this);
|
||||||
};
|
};
|
||||||
ResolutionMenuButton.prototype.buildCSSClass = function(){
|
ResolutionMenuButton.prototype.buildCSSClass = function(){
|
||||||
|
videojs.dom.addClass(this.el(), 'vjs-resolution-button')
|
||||||
return MenuButton.prototype.buildCSSClass.call( this ) + ' vjs-resolution-button';
|
return MenuButton.prototype.buildCSSClass.call( this ) + ' vjs-resolution-button';
|
||||||
};
|
};
|
||||||
MenuButton.registerComponent('ResolutionMenuButton', ResolutionMenuButton);
|
MenuButton.registerComponent('ResolutionMenuButton', ResolutionMenuButton);
|
||||||
|
@ -151,7 +163,6 @@
|
||||||
*/
|
*/
|
||||||
player.currentResolution = function(label, customSourcePicker){
|
player.currentResolution = function(label, customSourcePicker){
|
||||||
if(label == null) { return this.currentResolutionState; }
|
if(label == null) { return this.currentResolutionState; }
|
||||||
|
|
||||||
// Lookup sources for label
|
// Lookup sources for label
|
||||||
if(!this.groupedSrc || !this.groupedSrc.label || !this.groupedSrc.label[label]){
|
if(!this.groupedSrc || !this.groupedSrc.label || !this.groupedSrc.label[label]){
|
||||||
return;
|
return;
|
||||||
|
@ -181,7 +192,8 @@
|
||||||
player.handleTechSeeked_();
|
player.handleTechSeeked_();
|
||||||
if(!isPaused){
|
if(!isPaused){
|
||||||
// Start playing and hide loadingSpinner (flash issue ?)
|
// Start playing and hide loadingSpinner (flash issue ?)
|
||||||
player.play().handleTechSeeked_();
|
player.play();
|
||||||
|
player.handleTechSeeked_();
|
||||||
}
|
}
|
||||||
player.trigger('resolutionchange');
|
player.trigger('resolutionchange');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue