How to display a youtube video after stopping


#1

Hello Hype team!

I have a YouTube video on my scene, which I activate with a button. I used the “emptyInnerHTML” function to stop the video when I click on another button – works great. However, when I click on the first button, the video doesn’t appear. How do I get the video to display again? I’m assuming there’s another function/variable involved, but my coding knowledge is very shallow.


#2

The “emptyInnerHTML” function I’m assuming is just something like ...innerHTML = "";

which in effect is getting rid of the youtube video.

Can you upload a version of your document and I’ll see what I can do?

There are some posts here on using Youtube videos in Hype. Have you looked at those. Understand completely if you cannot follow them. You can use a youtube API which gives you controls like play, pause, on end do something, etc.


#3

Thanks for the quick response! Correct, I’m using innerHTML = " ", which I found on this thread in the forums. I’ve trolled the forums, and this is the only reference I could find to this problem.

I don’t actually want to get rid of the video, just stop it from playing.

I’ve uploaded a simplified version of my document; it’s a bit big to send the whole thing.

Any help would be greatly appreciated!video_test.hype.zip (52.3 KB)


#4

Here is a solution. It uses the Youtube API via a script in the Head HTML.

Instead of a HTML Widget I’ve used a Rectangle Element and inside that placed this code which gets replaced by the youtube iFrame

<div id="player"></div>

from then on you need to edit the Head HTML and add a function at the bottom

stopVideo = function () {
    player.stopVideo();
  }

you can then call this from anywhere in Hype to stop the video.

video_test-vDBear.hype.zip (24.0 KB)


Website loading
#5

Thanks! I’ll definitely give it a try.


(chans) #6

not work with HTML widget. it only work with rectangle, but if I use many rectangle , my web is very slow.