Playing Audio on Scene Load

I understand that iOS does not allow playing audio on Scene Load. However, I have a document where audio is set to play onScene load on each of several scenes. I have a persistent symbol for navigation, where there are arrows moving each scene left and right as well as numbers that represent each scene for the user to jump around to the various scenes.

When the user shifts through each scene using the arrows the audio does not play on scene load. If the user taps one of the numbers to jump to a scene the audio plays when the scene loads. After doing this the audio plays on each scene load when the user uses the arrows to scroll to each scene.

What is going on here? Is there a way I can get the audio to play on scene load using the arrows. without the user first using the number to jump to a scene? The file is too large to share here.

Audio will play on scene load if the touch action that triggers it occurs within about 100ms. If you have a transition (after tap and before the 'scene load') that increases this delay, iOS will assume you didn't mean for audio to start blaring out of your device.

Does the audio play for you on desktop browsers?

1 Like

Thanks Daniel.
So if I began the experience with a scene that simple said, “Click Here To Begin” and then it transitioned to the next with audio onSceneload that should work in theory…? Any other recommendations?

Everything works as expected in a browser

Thank you!

That should work for you – Hype will preload audio elements if you have ‘preload’ checked (by default). Test it out and let me know if you see (or hear) any issue.

You may run into issues if you have several audio elements preloaded, especially on slower mobile devices.

Ok, thank you. I guess my question (I think I know the answer to) is there any way to have audio begin without the user having to do anything?

thanks
Matt

Only if they've installed your app from the app store. (This is a restriction in Mobile Safari)

I have an interactive childrens book where I have this huge Start button at the beginning of the the book. This button triggers an audio file (I guess this could be just one second of silence, but I have this Pling going), and starts the book. The user don´t see this as an “play audio” action, just a start button. The rest of the book plays audio as it should after this start button :slight_smile:

What if, and I’m sidetracking a bit here you want a secondary audio to hit after the first one with a delay or a condition. I had cases in hype where i had onPress = trigger audio with function which worked great. But then i did onPress IF x = y THEN play audio. As soon as it had the if statement the audio refused to play. I was wondering if you’ve ever tried making any hacks or ways around playing multiple audio tracks or a sequence with a single button click. Thanks!

The general hack is that you’d make a Web Audio API buffer and keep it open, feeding data whenever you needed to play something. I’m not sure about the battery impact on this, and it isn’t simple JavaScript (nor would it work in every context since the Web Audio API isn’t supported by all browsers yet).

If you wanted to use the HTML5 audio tag you might be able to use one big audio file and then seek around and play once it has already played once. That’s just a guess though!

I know this is three years olf but I just want to confirm that it still remains true that there is no way to include audio that will auto load with a scene…

I have 8 scenes in a document that I had wanted to have music play over the first 1-2 if possible. I’m thinking… not possible :slight_smile:

You can load audio on the start of a scene if you transition to that scene with a click and the scene transition is extremely fast (ideally using the instant transition). The audio start event needs to happen in response to a click. You could make an audio file setup to play when visiting a web page, but browsers will simply ignore it. There was a dark time when everyone would play furelise.mid on their websites and we’re still trying to atone for our sins.

LOL. Well this would be the first scene in my animation so I was right that in this case, it’s not possible.
Thanks for clarifying :slight_smile:

1 Like