diff --git a/src/players/YouTube.js b/src/players/YouTube.js index 86c80234..a318140f 100644 --- a/src/players/YouTube.js +++ b/src/players/YouTube.js @@ -108,7 +108,12 @@ export default class YouTube extends Base { this.player.pauseVideo() } stop () { - if (!this.isReady || !this.player.stopVideo) return + const playerNode = this.player && this.player.getIframe && this.player.getIframe() + // the iframe is cached, so we need to try and retrieve it from the + // document to be sure of its existence in the DOM. + const isPlayerInDOM = !!document.getElementById(playerNode && playerNode.id) + + if (!this.isReady || !this.player.stopVideo || !isPlayerInDOM) return this.player.stopVideo() } seekTo (fraction) {