Bonjour! - at least here in California
The following code in the function “playPauseBtnToggle” uses the jQuery JavaScript Library which is placed in the “Head HTML” of the Hype document:
<script src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
Description:
• Clicking the “Play” button hides it and shows the “Pause” button, plays the sound.
• Clicking the “Pause” button hides it, and shows the “Play” button, pausing the sound.
• Each button calls the following function “playPauseBtnToggle” when clicked on.
• “yourSoundTrack” is the name of your audio file.
function playPauseBtnToggle(hype document, element, event) {
$("#Pause_Btn").toggle(); // toggle "Pause" button visibility (jQuery code)
$("#Play_Btn").toggle(); // toggle "Play" button visibility (jQuery code)
var isPlaying = document.getElementById("yourSoundTrack");
(isPlaying.paused) ? isPlaying.play() : isPlaying.pause(); // ternary operator
}
**Later Edit:**
If You wanted to make the line that does the actual "Play & Pause":
`(isPlaying.paused) ? isPlaying.play() : isPlaying.pause();`
accessible to other elements in this particular scene, You could put the following code in the "On Scene Load" handler in the Scene Panel:
function audiosetUp(hypeDocument. element, event) {
window.isPlaying = document.getElementById("yourSoundTrack");
}
This function makes creates a global variable called “isPlaying”.
Now by just inserting the line
(isPlaying.paused) ? isPlaying.play() : isPlaying.pause();
in other functions in this scene You can pause and play “yourSoundTrack”.
The code for the function that the Play & Pause buttons use would now be:
function playPauseBtnToggle(hypeDocument. element, event) {
$("#Pause_Btn").toggle();
$("#Play_Btn").toggle();
(isPlaying.paused) ? isPlaying.play() : isPlaying.pause();
}
The line from my first example (before the “Later Edit”):
var isPlaying = document.getElementById("yourSoundTrack");
is no longer necessary.
This second example is slightly more involved than the first, but offers more utility.