Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Restart embed YouTube video with vanilla JS?

$
0
0

When I click on the overlay I want to stop the embed YouTube video and restart is so far I have this code but it when it closes its still going and not bother to stop and not giving any error.

function closeToogle(){  console.log(iframes);  for (let portfolioItem of portfolioItems){    for(let iframe of iframes){      setTimeout(function(){        iframes[0].contentWindow.postMessage('{"event":"command", "func":"stopVideo","args":""}', '*');      }, 500); // add a 500ms delay      iframe.style.pointerEvents = "none";    }    portfolioItem.classList.add("hover-effect")    portfolioItem.removeAttribute("id", "toogle")    portfolioItem.removeAttribute("controls", "visable")    overlayDiv.removeAttribute("id")  }}

I thought that it needs time to realize I want to close that's the only reason there is a delay on it, it might not even needed


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>