diff options
Diffstat (limited to 'src/js/plyr.js')
-rw-r--r-- | src/js/plyr.js | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js index 87fb014a..af9d57bf 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -81,7 +81,6 @@ class Plyr { // Captions this.captions = { enabled: null, - tracks: null, currentTrack: null, }; @@ -116,7 +115,7 @@ class Plyr { this.console.log('Support', support); // We need an element to setup - if (this.media === null || utils.is.undefined(this.media) || !utils.is.htmlElement(this.media)) { + if (utils.is.nullOrUndefined(this.media) || !utils.is.htmlElement(this.media)) { this.console.error('Setup failed: no suitable element passed'); return; } @@ -665,6 +664,14 @@ class Plyr { return; } + // Toggle captions based on input + this.toggleCaptions(!utils.is.empty(input)); + + // If empty string is passed, assume disable captions + if (utils.is.empty(input)) { + return; + } + // Normalize const language = input.toLowerCase(); @@ -673,20 +680,17 @@ class Plyr { return; } - // Reset UI - this.toggleCaptions(true); - // Update config this.captions.language = language; - // Trigger an event - utils.dispatchEvent.call(this, this.media, 'languagechange'); - // Clear caption - captions.set.call(this); + captions.setText.call(this, null); + + // Update captions + captions.setLanguage.call(this); - // Re-run setup - captions.setup.call(this); + // Trigger an event + utils.dispatchEvent.call(this, this.media, 'languagechange'); } get language() { |