I am trying to stop the embedded video of Youtube from code so can someone help me in this?
<div class="youtube-video"><iframe width="853" height="480" src="https://www.youtube.com/embed/uisBaTkQAEs" class="abc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div><script> document.querySelector(".youtube-div").addEventListener('click', function(e){ if(e.target != document.querySelector(".youtube-video") ) { youtubeDiv.style.visibility = "hidden"; // player.stopVideo(); } });
So , this is my code where when i click a button youtube opens and i can play video.After we click outside of youtube , the youtube-div gets hidden. But when we hide the div again , i want to stop the video , tried using player.stopVideo() , but i dont get this nor does it works.