Audio playing across scenes

You have in the past responded on how to hide and load a music file automatically with a scene by clearing Controls checkbox in Properties > General > Media to hide the audio and checking Autoplay.

How can I enable the music file to continue playing on the second and third scene. Movement from one scene to another is enabled by an Event Handler on buttons which trigger Next Scene or Scene 2_1.

Thanks!

Hi Shawn,

Please see this thread:

Regards

Is there something I am doing wrong? I have attached it to the Scene Activate event …

Landing page.saolapack (912.5 KB)

You’re not playing the audio, just loading it.

if (!doc.myAudio) { doc.myAudio = new Audio('resources/behind-the-lens-steven-gutheinz-musicbed.mp3')}
doc.myAudio.play();

Additionally, you may need to use a user event such as a mouse click to start the audio.

Got it!

Much appreciated.

Audio seems to be the flavor of the month!

After much trial and error, I have defined a few issues I am facing. The first 2 points works in Edge but not in Chrome (76) and Firefox

  1. Audio isn’t playing across scenes – click blue button on Scene 1 to go to Scene 2 or 3 (I thought I had figured this out from this thread, but apparently not :frowning: )
  2. Audio doesn’t Autoplay in Chrome – need to click on screen to start it
  3. How do you create a pause / play button? I have tried pause via the green button (per code in other thread on audio) – but it doesn’t Pause the audio. Also, how can I make the same button a Toggle switch for Pause and Play?

Audio mechanisms.saolapack (919.5 KB)

Any ideas help would be most, most appreciated!

Thank you,

Shawn

Hi Shawn,

  1. The sound you hear is from the audio element on the first scene, not the audio created by your code.
  2. It’s the autoplay policy on some browsers. Audio must be started by an user interaction.
  3. The same reason as 1.

Please see this fixed project: Audio mechanisms fixed.saolapack (919.3 KB)

Regards

Thank you so very much!