mirror of
https://github.com/iv-org/videojs-quality-selector.git
synced 2024-10-01 06:35:49 -04:00
Ensure the correct resolution is selected on player 'ready'
This commit is contained in:
parent
26da31607d
commit
449a0a54d7
@ -23,8 +23,6 @@ module.exports = function(videojs) {
|
||||
constructor: function(player, options) {
|
||||
MenuButton.call(this, player, options);
|
||||
|
||||
this.selectedSource = options.selectedSource || player.currentSource();
|
||||
|
||||
player.on(events.QUALITY_SELECTED, function(event, source) {
|
||||
this.setSelectedSource(source);
|
||||
}.bind(this));
|
||||
@ -32,6 +30,7 @@ module.exports = function(videojs) {
|
||||
// Since it's possible for the player to get a source before the selector is
|
||||
// created, make sure to update once we get a "ready" signal.
|
||||
player.one('ready', function() {
|
||||
this.selectedSrc = player.src();
|
||||
this.update();
|
||||
}.bind(this));
|
||||
},
|
||||
@ -42,7 +41,7 @@ module.exports = function(videojs) {
|
||||
* @param source {object} player source to display as selected
|
||||
*/
|
||||
setSelectedSource: function(source) {
|
||||
this.selectedSource = source;
|
||||
this.selectedSrc = source ? source.src : undefined;
|
||||
this.update();
|
||||
},
|
||||
|
||||
@ -60,7 +59,7 @@ module.exports = function(videojs) {
|
||||
return _.map(sources, function(source) {
|
||||
return new QualityOption(player, {
|
||||
source: source,
|
||||
selected: this.selectedSource ? source.src === this.selectedSource.src : false,
|
||||
selected: source.src === this.selectedSrc,
|
||||
});
|
||||
}.bind(this));
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user