mirror of
https://gitea.invidious.io/iv-org/videojs-quality-selector.git
synced 2024-08-15 00:43:13 +00:00
Ensure the correct resolution is selected on player 'ready'
This commit is contained in:
parent
26da31607d
commit
449a0a54d7
1 changed files with 3 additions and 4 deletions
|
@ -23,8 +23,6 @@ module.exports = function(videojs) {
|
||||||
constructor: function(player, options) {
|
constructor: function(player, options) {
|
||||||
MenuButton.call(this, player, options);
|
MenuButton.call(this, player, options);
|
||||||
|
|
||||||
this.selectedSource = options.selectedSource || player.currentSource();
|
|
||||||
|
|
||||||
player.on(events.QUALITY_SELECTED, function(event, source) {
|
player.on(events.QUALITY_SELECTED, function(event, source) {
|
||||||
this.setSelectedSource(source);
|
this.setSelectedSource(source);
|
||||||
}.bind(this));
|
}.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
|
// 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.
|
// created, make sure to update once we get a "ready" signal.
|
||||||
player.one('ready', function() {
|
player.one('ready', function() {
|
||||||
|
this.selectedSrc = player.src();
|
||||||
this.update();
|
this.update();
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
@ -42,7 +41,7 @@ module.exports = function(videojs) {
|
||||||
* @param source {object} player source to display as selected
|
* @param source {object} player source to display as selected
|
||||||
*/
|
*/
|
||||||
setSelectedSource: function(source) {
|
setSelectedSource: function(source) {
|
||||||
this.selectedSource = source;
|
this.selectedSrc = source ? source.src : undefined;
|
||||||
this.update();
|
this.update();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -60,7 +59,7 @@ module.exports = function(videojs) {
|
||||||
return _.map(sources, function(source) {
|
return _.map(sources, function(source) {
|
||||||
return new QualityOption(player, {
|
return new QualityOption(player, {
|
||||||
source: source,
|
source: source,
|
||||||
selected: this.selectedSource ? source.src === this.selectedSource.src : false,
|
selected: source.src === this.selectedSrc,
|
||||||
});
|
});
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue