Back to the Shapespark home page

Stop video on viewer.onViewSwitchStarted();

I’ve created a a scene with a few video and audio spots. In some use cases, the user may leave the area before the video is over… and even jump into another area with a looping video.

I’d like to trigger some sore of stop() for certain videos once a user moves to another area.

I would think viewer.onViewSwitchStarted(); could be of use, just not sure how to call a specific video and stop it.

Thanks for the help.

@jonalex, this thread describes how to play/pause a video texture.

To access a given video texture, please first find a scene material using Viewer.findMaterial described in https://forum.shapespark.com/t/api-video-not-playing-after-paused/1654:

const material = viewer.findMaterial('<MATERIAL-NAME>');

and then get the video texture:

const videoTexture = material.baseColorTexture

For this to work the material must be marked as editable before the scene is loaded.