Play and Pause audio with train image

Hi everyone! I have a train image that shoots an animation and synchronized audio. I don’t get the following script to work to make my audio pause when the train image is not visible and put on play when it is.

const BIENVENIDA1_COMPLETOOK_wav = parent;

symbol.nodes.Bienvenida.on(“seen”, () => {
// Runs when seen occurs on the Bienvenida node
symbol.nodes.BIENVENIDA1_COMPLETOOK_wav.start;

symbol.nodes.Bienvenida.on(“notseen”, () => {
// Runs when notseen occurs on the Bienvenida node
symbol.nodes.BIENVENIDA1_COMPLETOOK_wav.pause;
});

});

I’m putting this script inside the audio file BIENVENIDA1_COMPLETOOK_wav.

I leave the project in case someone can take a few minutes to help me, I will be very grateful! PRINCIPITO BIENVENIDA 1.zpp (19.5 MB)

Hi @museodeplayaunion. It seems to be doing what you want now playing on seen, pausing on not/seen. I’m not 100% sure but you had a lot of audio start and stop points and triggers happening. I think they might have been competing against each other.

I consolidated the seen/notseen event and start/pause into one script you will see in the hierarchy. Take a look and let me know if you have any questions.

PRINCIPITO BIENVENIDA_seen-notseen_working.zpp (19.5 MB)

3 Likes

Thanks for the prompt response! I restarted the project from scratch and now it works. Thank you very much again!