Cant Pause Vimeo stream

Ive read the forums but can seem to get this to work…
I have a hype doc with a number of scenes and there is embedded Vimeo video on at least 6 of them
I have a button that overlays the video to show a text version only and I want the video to pause at that point as well as on scene unload.
The one I got partially working was by using this in the html head

and this js function

var videoRectangle = hypeDocument.getElementById(‘videoRectangle’)

var iframe = videoRectangle.childNodes[0];

var player = $f(iframe);

player.api("pause");

I given the video element a unique id of videoRectangle

I had it working intermittently on one video but not across the scenes where I need the videos to pause when the text only button is selected or the scene unloaded

presuppose that you scriptlines work for one instance, you can make it working for reuse by using a class instead of id for the video and the sceneelement as root.

	var sceneElement = document.getElementById(hypeDocument.currentSceneId());
	var videoRectangle = sceneElement.querySelector('.videoRectangle');

var iframe = videoRectangle.childNodes[0];

var player = $f(iframe);

player.api("pause");
1 Like

Thanks Hans, not my strong point so Im struggling trying to understand that

Hans means you should add a class named videoRectangle instead of using a unique id. Then adjust the query to a look for the class instead of the id.

1 Like

I managed to get it to work. Not a very elegant solution but it works - had to use a different js for each video

1 Like