mirror of
https://gitea.invidious.io/iv-org/videojs-quality-selector.git
synced 2024-08-15 00:43:13 +00:00
fix: Update menu when sources are set after player is ready (#47)
Fixes #47
This commit is contained in:
parent
12bd19a69e
commit
a3753ddb65
3 changed files with 11 additions and 0 deletions
|
@ -34,6 +34,11 @@ module.exports = function(videojs) {
|
||||||
});
|
});
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
// Update the list of menu items only when the list of sources change
|
||||||
|
player.on(events.PLAYER_SOURCES_CHANGED, function() {
|
||||||
|
this.update();
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
player.on(events.QUALITY_SELECTED, function(event, newSource) {
|
player.on(events.QUALITY_SELECTED, function(event, newSource) {
|
||||||
// Update the selected source with the source that was actually selected
|
// Update the selected source with the source that was actually selected
|
||||||
this.setSelectedSource(newSource);
|
this.setSelectedSource(newSource);
|
||||||
|
|
|
@ -4,5 +4,6 @@ module.exports = {
|
||||||
|
|
||||||
QUALITY_REQUESTED: 'qualityRequested',
|
QUALITY_REQUESTED: 'qualityRequested',
|
||||||
QUALITY_SELECTED: 'qualitySelected',
|
QUALITY_SELECTED: 'qualitySelected',
|
||||||
|
PLAYER_SOURCES_CHANGED: 'playerSourcesChanged',
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,6 +17,11 @@ module.exports = function(videojs) {
|
||||||
player._qualitySelectorSafeSeek.onPlayerSourcesChange();
|
player._qualitySelectorSafeSeek.onPlayerSourcesChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_.isEqual(sources, player._qualitySelectorPreviousSources)) {
|
||||||
|
player.trigger(events.PLAYER_SOURCES_CHANGED, sources);
|
||||||
|
player._qualitySelectorPreviousSources = sources;
|
||||||
|
}
|
||||||
|
|
||||||
// There are generally two source options, the one that videojs
|
// There are generally two source options, the one that videojs
|
||||||
// auto-selects and the one that a "user" of this plugin has
|
// auto-selects and the one that a "user" of this plugin has
|
||||||
// supplied via the `selected` property. `selected` can come from
|
// supplied via the `selected` property. `selected` can come from
|
||||||
|
|
Loading…
Reference in a new issue