Hello,
I’m having a really tough problem for me, and I found no answer so far, even if the problem may seem basic.
I need to stop a Youtube or Vimeo video, which is nested in div in the index.html
<div>
<iframe id="video" class="video" width="500" height="281" src="http://www.youtube.com/embed/0sN4MHZpmeo?enablejsapi=1&version=3&playerapiid=ytplayer&rel=0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen allowscriptaccess="always"></iframe>
</div>
In the MyProject_app.js I have a function
app.ExternalInterface.stopVideos = function () {
var videos = document.querySelectorAll('iframe, video');
Array.prototype.forEach.call(videos, function (video) {
if (video.tagName.toLowerCase() === 'video') {
video.pause();
} else {
var src = video.src;
video.src = src;
}
});
};
On object being pressed, the function is being executed (sure about that), but with no effect on the video. The function comes from some js forum and is believed to work.
I want the Youtube video to be paused.
Can you help please? Thank you.