fix: Update menu when sources are set after player is ready (#47)

Fixes #47
This commit is contained in:
Matt Luedke 2019-11-20 10:24:02 -05:00
parent 12bd19a69e
commit a3753ddb65
3 changed files with 11 additions and 0 deletions

View File

@ -34,6 +34,11 @@ module.exports = function(videojs) {
});
}.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) {
// Update the selected source with the source that was actually selected
this.setSelectedSource(newSource);

View File

@ -4,5 +4,6 @@ module.exports = {
QUALITY_REQUESTED: 'qualityRequested',
QUALITY_SELECTED: 'qualitySelected',
PLAYER_SOURCES_CHANGED: 'playerSourcesChanged',
};

View File

@ -17,6 +17,11 @@ module.exports = function(videojs) {
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
// auto-selects and the one that a "user" of this plugin has
// supplied via the `selected` property. `selected` can come from