Move internal event listeners for captions with direct handling in the captions object
This commit is contained in:
parent
fa5d0ad316
commit
6ce9a94932
@ -128,6 +128,7 @@ const captions = {
|
||||
}
|
||||
},
|
||||
|
||||
// Used internally for toggleCaptions()
|
||||
toggle(input) {
|
||||
// If there's no full support
|
||||
if (!this.supported.ui) {
|
||||
@ -146,10 +147,19 @@ const captions = {
|
||||
// Update state and trigger event
|
||||
if (active !== this.captions.active) {
|
||||
this.captions.active = active;
|
||||
triggerEvent.call(this, this.media, this.captions.active ? 'captionsenabled' : 'captionsdisabled');
|
||||
|
||||
// Update UI
|
||||
controls.updateSetting.call(this, 'captions');
|
||||
|
||||
// Save to storage
|
||||
this.storage.set({ captions: active });
|
||||
|
||||
// Trigger event (not used internally)
|
||||
triggerEvent.call(this, this.media, active ? 'captionsenabled' : 'captionsdisabled');
|
||||
}
|
||||
},
|
||||
|
||||
// Used internally for currentTrack setter
|
||||
set(index, setLanguage = true, show = true) {
|
||||
const tracks = captions.getTracks.call(this);
|
||||
|
||||
@ -187,7 +197,13 @@ const captions = {
|
||||
this.embed.enableTextTrack(language);
|
||||
}
|
||||
|
||||
// Trigger event
|
||||
// Update UI
|
||||
controls.updateSetting.call(this, 'captions');
|
||||
|
||||
// Save to storage
|
||||
this.storage.set({ language });
|
||||
|
||||
// Trigger event (not used internally)
|
||||
triggerEvent.call(this, this.media, 'languagechange');
|
||||
}
|
||||
|
||||
@ -202,6 +218,7 @@ const captions = {
|
||||
}
|
||||
},
|
||||
|
||||
// Used internally for language setter
|
||||
setLanguage(language, show = true) {
|
||||
if (!is.string(language)) {
|
||||
this.debug.warn('Invalid language argument', language);
|
||||
|
@ -387,24 +387,6 @@ class Listeners {
|
||||
controls.updateSetting.call(this.player, 'quality', null, event.detail.quality);
|
||||
});
|
||||
|
||||
// Caption language change
|
||||
on.call(this.player, this.player.media, 'languagechange', () => {
|
||||
// Update UI
|
||||
controls.updateSetting.call(this.player, 'captions');
|
||||
|
||||
// Save to storage
|
||||
this.player.storage.set({ language: this.player.language });
|
||||
});
|
||||
|
||||
// Captions toggle
|
||||
on.call(this.player, this.player.media, 'captionsenabled captionsdisabled', () => {
|
||||
// Update UI
|
||||
controls.updateSetting.call(this.player, 'captions');
|
||||
|
||||
// Save to storage
|
||||
this.player.storage.set({ captions: this.player.captions.active });
|
||||
});
|
||||
|
||||
// Proxy events to container
|
||||
// Bubble up key events for Edge
|
||||
on.call(this.player, this.player.media, this.player.config.events.concat([
|
||||
|
Loading…
x
Reference in New Issue
Block a user