Stop sound restarting main timeline

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