Stopping Audio within an Rectangle Video Element

Hi there,

I have found the following javascript (added below) to stop audio from an embedded html video when leaving a layout or scene, however I have embedded my video using a rectangle element. Is there another version of javascript which will give the same result?

Thanks

var emptyInnerHTML = '';
hypeDocument.getElementById("video1").innerHTML = emptyInnerHTML

Think I have managed to resolve this…

I am running the following Javascript onSceneUnload:

    var Element = hypeDocument.getElementById("video1");
	
	my.player.pauseVideo();
2 Likes

This actually does not look like it would work (pauseVideo is not a thing), and my.player (at least based on your code) isn't an object. Can you share what you have?

I haven’t seen ‘pauseVideo’ before but it seems to have worked.

I have linked below a sample project as maybe there is a better solution to achieve what I am looking for.

Working Autoplay Sent to Daniel.zip (22.9 KB)

I am looking for the embedded YouTube video to stop if a new layout has triggered or if a new scene has opened. Before I added this code (pauseVideo) the audio would still be playing in the background even if viewing another scene or change of layout. I found the code I linked in my first post but this doesn’t work as I have embedded the YouTube video within a rectangle element which you can see in the sample project.

Thanks