Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate Iframe/video player being added #92

Closed
billyswifty opened this issue Aug 5, 2021 · 2 comments · Fixed by #97
Closed

Duplicate Iframe/video player being added #92

billyswifty opened this issue Aug 5, 2021 · 2 comments · Fixed by #97

Comments

@billyswifty
Copy link

After the play button is clicked, the script inserts duplicate <iframe> YouTube players onto the page and plays them both. So I hear duplicate audio tracks, and if I pause the video, the duplicate is still playing in the background. I have tested in multiple browsers. This is the page I am currently testing on.

Screen Shot 2021-08-05 at 8 11 44 AM

<head>
  <link rel="stylesheet" href="/lite-youtube-embed/src/lite-yt-embed.css" />
  <script>
    $(document).ready(function() {
        if ( $("#youtube-lite-script").length == 0 ) {
          let yt_script = document.createElement("script");
          yt_script.setAttribute("src", "/assets/lite-yt-embed.js");
          yt_script.setAttribute("id", "youtube-lite-script");
          document.body.appendChild(yt_script);
        }
      });
  </script>
</head>
<div class="iframe-holder">
  <lite-youtube class="fake-video" videoid="EQbxkhkuKsM" params="rel=0&origin=https://junkyardbots2.caboosecms.com" playlabel="Play Video"></lite-youtube>
</div>
@denFete
Copy link

denFete commented Sep 21, 2021

Got the same issue.... @billyswifty Have you solved it somehow?

@thomasali
Copy link

Getting the same issue, currently adding the following to the start of the addIframe() method:

addIframe() {
    if(jQuery(this).children('iframe').length > 0) {
        // If there is already an iframe return as we don't want to create another
        return;
	}
	...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants