We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Stop a Youtube or Vimeo video from a puzzle

Home Forums Programming Stop a Youtube or Vimeo video from a puzzle

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #25260
    gregkoralewski
    Participant

    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.

    #25274

    Hi,

    Not sure what’s wrong. You could try adding ‘console.log()’ to different parts of this function to see what’s going on.

    Chief 3D Verger | LinkedIn | Twitter

    #25324
    GLiFTeK
    Customer

    are you sure the syntax / formatting is accurate in this part?…
    ('iframe, video');

    also instead of
    var videos = document.querySelectorAll('iframe, video');

    possibly try
    var videos = window.parent.querySelectorAll('iframe, video');

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.