Skip to content

Commit

Permalink
Merge pull request #80 from hyperaudio/79-multiple-youtube-player-sup…
Browse files Browse the repository at this point in the history
…port

79 fix for multiple youtube players (hyperaudio lite update)
  • Loading branch information
maboa authored Mar 17, 2022
2 parents 9827b6f + e0b0931 commit ba6fc3d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions wp-hyperaudio/js/hyperaudio-lite.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -554,4 +560,4 @@ if (typeof module !== 'undefined' && module.exports) {
module.exports = { HyperaudioLite };
}

//export default HyperaudioLite;
//export default HyperaudioLite;

0 comments on commit ba6fc3d

Please sign in to comment.