Jump to content

Chrome mobile not playing audio files from JS :/


Ezelia
 Share

Recommended Posts

Hi everyone,

 

I'm encoutring a strange behaviour from chrome mobile ... it's not playing my audio files from JavaScript

I tried with audio API (new Audio() ) with buzzjs and howlerjs libraries ... nothing works.

 

the same code works just find with desktop browsers, Android stock browser and Firefox mobile.

 

 

also, if I include an <audio> tag to the document and try to control the element from javascript I can't play it the fist time, but if I click the play button then the sound start playing and this time I can control it throught Javascript.

 

here is a page with the code example : http://ezelia.com/demo/audio.html the audio should start automatically (check from desktop) ... but on chrome mobile it won't autoplay, you must click on "Play" button

 

any idea ?

Link to comment
Share on other sites

Audio on most mobile browsers (iOS / Chrome) require a touch event before it can start. If using Web Audio all audio is put in a 'scheduled' state until a touch event is received, only then can you play it. Same for audio tag. You need to design your game around it. One of the best ways I've seen is to have audio off by default and on the main menu have a "music on" button - and of course touching it allows you to start the audio going.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...