Home > Technical & Creative Skills > Programming, Servers & Scripts

Mobile Audio Help! (6)


02-03-2017 05:18 AM #1 xkjonz (Member)
Mobile Audio Help!

Hi guys,

I have to ask for help again because I just realized that my lander's audio only works when I load the page using desktop. It doesn't work at all when I open it on mobile.

Can anyone help?

Here's the script I'm using:

Code:
<audio autoplay="autoplay">  
   <source src="audio.ogg" />  
   <source src="audio.mp3" />  
</audio>


02-03-2017 05:50 AM #2 erikgyepes (Moderator)

Mobile browsers doesn't support autoplay.

However this library does some tricks to make it work: https://howlerjs.com/, check it out.


02-03-2017 08:14 AM #3 xkjonz (Member)

Thanks but I tried it and it still didn't work


02-03-2017 08:33 AM #4 erikgyepes (Moderator)

On what kind of mobile phone and browser are you doing your tests?

This script works well for me, combine it with your + make sure alert.mp3 is available:

<script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.0.0/howler.core.min.js"></script>
<script>
var sound = new Howl({
src: ['alert.mp3'],
autoplay: true,
volume: 1
});
</script>


02-04-2017 09:05 AM #5 xkjonz (Member)

It works! Thanks!

I think I forgot to put the volume: 1, that's why it wasn't working.


02-04-2017 11:30 AM #6 erikgyepes (Moderator)

Haha, happens

Glad you got it working!


Home > Technical & Creative Skills > Programming, Servers & Scripts