From 70feb2c7c46fafdb8a7c906ddd6b847f651d0169 Mon Sep 17 00:00:00 2001 From: Antonio Laguna Date: Mon, 20 Mar 2017 09:16:53 +0100 Subject: [PATCH] Odd workaround --- src/js/plugins/youtube.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/js/plugins/youtube.js b/src/js/plugins/youtube.js index b6aff60..c396d06 100644 --- a/src/js/plugins/youtube.js +++ b/src/js/plugins/youtube.js @@ -1,5 +1,4 @@ /* global YT */ - import DOM from '../utils/dom'; import Slide from '../modules/slide'; @@ -24,6 +23,9 @@ class Player { events: { onReady: () => { this.ready = true; + if (this.timeout && this.player.getPlayerState() !== 1) { + this.play(); + } if (this.onReadyC) { this.onReadyC(); @@ -32,7 +34,9 @@ class Player { } } }); + this.el = this.player.getIframe(); + this.timeout = null; } /** @@ -40,6 +44,9 @@ class Player { */ play() { if (this.ready) { + this.timeout = setTimeout(() => { + this.timeout = null; + }, 1000); this.player.playVideo(); } else { this.onReadyC = this.play; @@ -134,7 +141,6 @@ export default class YouTube { * @param {Slide} slide */ static onSectionEnabled(slide) { - console.log('enabling', slide); // eslint-disable-line no-console slide.player.play(); } @@ -143,7 +149,6 @@ export default class YouTube { * @param {Slide} slide */ static onSectionDisabled(slide) { - console.log('disabling', slide); // eslint-disable-line no-console slide.player.pause(); } }