diff options
author | Albin Larsson <mail@albinlarsson.com> | 2018-06-15 12:56:58 +0200 |
---|---|---|
committer | Albin Larsson <mail@albinlarsson.com> | 2018-06-15 15:57:10 +0200 |
commit | 87ea5e14b46d606b5c33d753dec2d96fbec4d074 (patch) | |
tree | dbe77ce029e9214aca160025be908049585e2115 /src/js | |
parent | 2aa967aba93cb485ea2c4d10615cee505a354d15 (diff) | |
download | plyr-87ea5e14b46d606b5c33d753dec2d96fbec4d074.tar.lz plyr-87ea5e14b46d606b5c33d753dec2d96fbec4d074.tar.xz plyr-87ea5e14b46d606b5c33d753dec2d96fbec4d074.zip |
Replace provider switch plyr.js with conditions
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/plyr.js | 71 |
1 files changed, 29 insertions, 42 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js index 753db775..0217ded8 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -1028,50 +1028,37 @@ class Plyr { // Stop playback this.stop(); - // Type specific stuff - switch (`${this.provider}:${this.type}`) { - case 'html5:video': - case 'html5:audio': - // Clear timeout - clearTimeout(this.timers.loading); - - // Restore native video controls - ui.toggleNativeControls.call(this, true); - - // Clean up - done(); - - break; - - case 'youtube:video': - // Clear timers - clearInterval(this.timers.buffering); - clearInterval(this.timers.playing); - - // Destroy YouTube API - if (this.embed !== null && is.function(this.embed.destroy)) { - this.embed.destroy(); - } - - // Clean up - done(); - - break; - - case 'vimeo:video': - // Destroy Vimeo API - // then clean up (wait, to prevent postmessage errors) - if (this.embed !== null) { - this.embed.unload().then(done); - } - - // Vimeo does not always return - setTimeout(done, 200); + // Provider specific stuff + if (this.isHTML5) { + // Clear timeout + clearTimeout(this.timers.loading); + + // Restore native video controls + ui.toggleNativeControls.call(this, true); + + // Clean up + done(); + } else if (this.isYouTube) { + // Clear timers + clearInterval(this.timers.buffering); + clearInterval(this.timers.playing); + + // Destroy YouTube API + if (this.embed !== null && is.function(this.embed.destroy)) { + this.embed.destroy(); + } - break; + // Clean up + done(); + } else if (this.isVimeo) { + // Destroy Vimeo API + // then clean up (wait, to prevent postmessage errors) + if (this.embed !== null) { + this.embed.unload().then(done); + } - default: - break; + // Vimeo does not always return + setTimeout(done, 200); } } |