diff --git a/src/js/features/playpause.js b/src/js/features/playpause.js index 28e87a66..88a71abf 100644 --- a/src/js/features/playpause.js +++ b/src/js/features/playpause.js @@ -51,7 +51,8 @@ Object.assign(MediaElementPlayer.prototype, { play.innerHTML = generateControlButton(t.id, pauseTitle, playTitle, `${t.media.options.iconSprite}`, ['icon-play', 'icon-pause', 'icon-replay'], `${t.options.classPrefix}`); play.addEventListener('click', () => { if (t.paused) { - t.play(); + var _promise = t.play(); + debug("play() returned promise at 'buildplaypause ... t.paused': ", _promise); } else { t.pause(); } diff --git a/src/js/features/progress.js b/src/js/features/progress.js index b9cf2b96..07c400f3 100644 --- a/src/js/features/progress.js +++ b/src/js/features/progress.js @@ -106,7 +106,8 @@ Object.assign(MediaElementPlayer.prototype, { // start again to track new time setTimeout(function() { - player.play(); + var _promise = player.play(); + debug("play() returned promise at 'start again to track new time': ", _promise); }, 0); } } @@ -144,7 +145,8 @@ Object.assign(MediaElementPlayer.prototype, { // start again to track new time setTimeout(function() { - player.play(); + var _promise = player.play(); + debug("play() returned promise at 'start again to track new time (#2)': ", _promise); }, 0); } } @@ -332,7 +334,8 @@ Object.assign(MediaElementPlayer.prototype, { */ restartPlayer = () => { if (new Date() - lastKeyPressTime >= 1000) { - t.play(); + var _promise = t.play(); + debug("play() returned promise at 'restartPlayer': ", _promise); } }, handleMouseup = () => { @@ -343,7 +346,8 @@ Object.assign(MediaElementPlayer.prototype, { } if (t.forcedHandlePause) { t.slider.focus(); - t.play(); + var _promise = t.play(); + debug("play() returned promise at 't.forcedHandlePause': ", _promise); } t.forcedHandlePause = false; } @@ -416,7 +420,8 @@ Object.assign(MediaElementPlayer.prototype, { case 32: // space if (IS_FIREFOX) { if (t.paused) { - t.play(); + var _promise = t.play(); + debug("play() returned promise at 'IS_FIREFOX ... t.paused': ", _promise); } else { t.pause(); } diff --git a/src/js/player.js b/src/js/player.js index 0a2a25b2..9091eaf5 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -256,7 +256,8 @@ class MediaElementPlayer { // override Apple's autoplay override for iPads if (IS_IPAD && t.node.getAttribute('autoplay')) { - t.play(); + var _promise = t.play(); + debug("play() returned promise at 'override Apple's autoplay override for iPads': ", _promise); } } else if ((t.isVideo || (!t.isVideo && (t.options.features.length || t.options.useDefaultControls))) && !(IS_ANDROID && t.options.AndroidUseNativeControls)) { @@ -577,7 +578,8 @@ class MediaElementPlayer { if (t.getCurrentTime() > 0 && t.currentMediaTime > 0) { t.setCurrentTime(t.currentMediaTime); if (!IS_IOS && !IS_ANDROID) { - t.play(); + var _promise = t.play(); + debug("play() returned promise at '!IS_IOS && !IS_ANDROID': ", _promise); } } }); @@ -623,7 +625,8 @@ class MediaElementPlayer { if (!t.isVideo && !t.options.features.length && !t.options.useDefaultControls) { // force autoplay for HTML5 if (autoplay && isNative) { - t.play(); + var _promise = t.play(); + debug("play() returned promise at 'force autoplay for HTML5': ", _promise); } if (t.options.success) { @@ -678,7 +681,8 @@ class MediaElementPlayer { if (t.paused && pressed) { t.pause(); } else if (t.paused) { - t.play(); + var _promise = t.play(); + debug("play() returned promise at 'else if (t.paused)': ", _promise); } else { t.pause(); } @@ -810,7 +814,8 @@ class MediaElementPlayer { } if (t.options.loop) { - t.play(); + var _promise = t.play(); + debug("play() returned promise at 't.options.loop': ", _promise); } else if (!t.options.alwaysShowControls && t.controlsEnabled) { t.showControls(); } @@ -904,7 +909,8 @@ class MediaElementPlayer { // force autoplay for HTML5 if (autoplay && isNative) { - t.play(); + _promise = t.play(); + debug("play() returned promise at 'autoplay && isNative': ", _promise); } if (t.options.success) { @@ -1357,7 +1363,8 @@ class MediaElementPlayer { layer.addEventListener('click', (e) => { if (t.options.clickToPlayPause) { if (t.paused) { - t.play(); + var _promise = t.play(); + debug("play() returned promise at 't.options.clickToPlayPause ... t.paused': ", _promise); } else { t.pause(); } @@ -1600,7 +1607,8 @@ class MediaElementPlayer { ; if (t.paused) { - t.play(); + var _promise = t.play(); + debug("play() returned promise at 't.paused': ", _promise); } else { t.pause(); } diff --git a/src/js/renderers/html5.js b/src/js/renderers/html5.js index a29484c0..d3040193 100644 --- a/src/js/renderers/html5.js +++ b/src/js/renderers/html5.js @@ -142,7 +142,8 @@ const HtmlMediaElement = { if (index < total && mediaFiles[(index + 1)] !== undefined) { node.src = mediaFiles[index++].src; node.load(); - node.play(); + var _promise = node.play(); + debug("play() returned promise at 'Reload the source only in case of the renderer is active at the moment': ", _promise); } else { mediaElement.generateError('Media error: Format(s) not supported or source(s) not found', mediaFiles); }