Stop sound restarting main timeline

I have started a music file with Group 1 / Start button and want to create a toggle pause / play with another button (Sound) but the Sound button on mouse click restarts the Main timeline??

How can I fix this?

Thank you.

BD1 2.zip (1.4 MB)

Moved the “Sound” button above the first “Group1” and it worked “properly” - sound stopped & no timeline restart.

MoveSndBtn

Brilliant! And do you know how I can make the Sound a toggle? I tried adding Play sound underneath and it stops it and starts up immediately.

image

Hype Demo: BD1 2 JHSv1.hype.zip (926.0 KB)

Note: This Demo uses your approach of triggering sounds (Play, Stop) in the Hype interface.

One (of many) techniques is to have two buttons, one (Start) on top of the other (Stop). In the attached demo clicking on the "Start" button triggers the function "hideStartBtn" which runs a one line script that hides the "Start" button and reveals the "Stop" button underneath (and also plays a sound via the "On Mouse Click" of the Hype interface):

element.style.display = "none";

The "Start" button is referenced here as "element" - that is the element that initiated the script (via a mouse click).


Clicking on the "Stop" button triggers the "showStartBtn" function which displays the "Start" button again (the sound is stopped via the "On Mouse Click" of the Hype interface):

startButton = hypeDocument.getElementById('startBtn');
startButton.style.display = "block";

More information about the "display" property is here.



Note: The "Start" button will always start the soundtrack from the beginning with this set-up no matter where it is stopped by the "Stop" button.

A "Play" ~ "Pause" arrangement (sound starts from the beginning or the point where it was paused) would be a different approach using code only... not the "Play Sound"~"Stop Sound" of the Hype interface.

Read this article for more information on scripting audio in Hype. HIGHLY recommended!

As I mentioned at the beginning of this post there are many techniques to create this toggling type of set-up, one version of which can use just a single button.

I think this is enough for now - somebody's bedtime. :sunglasses::zzz:

2 Likes