From e0b0931c1f2b34926c6f8910f4ba0a6dd11f90c6 Mon Sep 17 00:00:00 2001 From: Mark Boas Date: Thu, 17 Mar 2022 12:52:51 +0100 Subject: [PATCH] 79 fix for multiple youtube players (hyperaudio lite update) --- wp-hyperaudio/js/hyperaudio-lite.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wp-hyperaudio/js/hyperaudio-lite.js b/wp-hyperaudio/js/hyperaudio-lite.js index e6c5a6a..30c515f 100644 --- a/wp-hyperaudio/js/hyperaudio-lite.js +++ b/wp-hyperaudio/js/hyperaudio-lite.js @@ -1,5 +1,5 @@ /*! (C) The Hyperaudio Project. MIT @license: en.wikipedia.org/wiki/MIT_License. */ -/*! Version 2.0.9 */ +/*! Version 2.0.11 */ 'use strict'; @@ -84,7 +84,13 @@ class HyperaudioLite { const firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); + const previousYTEvent = window.onYouTubeIframeAPIReady; window.onYouTubeIframeAPIReady = () => { + + if (typeof previousYTEvent !== 'undefined') { // used for multiple YouTube players + previousYTEvent(); + } + this.player = new YT.Player(mediaElementId, { events: { onStateChange: onPlayerStateChange, @@ -554,4 +560,4 @@ if (typeof module !== 'undefined' && module.exports) { module.exports = { HyperaudioLite }; } -//export default HyperaudioLite; +//export default HyperaudioLite; \ No newline at end of file