How are you adding your sound? Timeline action? Dropping onto scene area? In HTML inside an element?
If you are dropping onto the scene area then you cannot manipulate it using Javascript (btw javascript is different to Java try not to mix them) because you cannot reference the audio with an id. You need to be able to access the <audio>
element.
If you are calling it using a timeline then again for the reasons stated above you cannot access in the same way.
You can access it however, if you are using code (<audio>
tag inside an element with an id=‘myAudio’) inside a rectangle or other element. This way you can use your shorthand javascript conditional statement.
(hypeDocument.getElementById('myAudio').paused) ? hypeDocument.getElementById('myAudio').play(); : hypeDocument.getElementById('myAudio').pause();
Another option is to create a new audio element on scene load using the following javascript.
window.audio = new Audio('${resourcesFolderName}/name-ofyour-file.mp3');
now you can use the following javascript with a button on mouse click.
(audio.paused) ? audio.play() : audio.pause();
Note window.audio
makes the variable belong to the browser window and can be called at anytime.