I found this instruction to be very helpful, and works like a charm . . .
Stopping Audio within an HTML Widget
- Select your HTML widget.
- Open the ‘Identity Inspector’ and fill in a value for the Unique Element ID. This ID will allow us to directly target the HTML widget. In this example, we’ll be using the ID video1
- Add the following code:
var emptyInnerHTML = ''; hypeDocument.getElementById("video1").innerHTML = emptyInnerHTML
Note : Audio playing within a standard audio or video element will stop when exiting the scene. Visit the Audio & Video documentation for more information.
I've placed embed code for a YouTube video in an HTML widget.
The widget is set to 0 percent scale and 0 percent visibility when the scene loads.
When the user clicks a play button, the widget animates to 100 percent scale and 100 percent visibility.
When the user clicks a close button, the widget animates back to 0 percent scale and 0 percent visibility. Emptying the innerHTML makes the audio stop.
But if the user clicks the play button again, the widget reanimates with an emptyHTML. How do I refill it with the original content if I do all this within the same scene?