diff options
| -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);          }      } | 
