-1

I have created a webpage using html and css, I wanted to start an audio file in the background automatically once the page is loaded. Thus I have used <audio> tag in my code.

Now, this works perfectly fine when I open my page in my desktop, but when I open same page through mobile's browser, audio does not starts automatically. It requires manual option.

Can anyone provide me with the solution?

halfer
  • 19,824
  • 17
  • 99
  • 186
Divya
  • 416
  • 5
  • 10
  • See if this helps you.. http://www.w3schools.com/tags/att_audio_autoplay.asp – Pranjal Jul 13 '16 at 06:08
  • 2
    Most mobile browsers prioritize reducing bandwidth over annoying autoplaying audio. – Alexander O'Mara Jul 13 '16 at 06:11
  • 1
    You seem to be new to StackOverflow, because you didn't provide us with any information on what you already tried to achieve and in which way it fails. For general purpose questions please result to search engines. --- That said I have to add: Autoplaying audio on a web site has been bad practice since years. It annoys people and it's abusive, forceful and drives away visitors. Do you know what your visitor likes or wants to hear? Why do you force a user to download data? I could name situations in which that could seriously harm someones business, reputation or private life. Just don't do it! – Seika85 Jul 13 '16 at 06:20
  • Addendum: If you really have to add autoplay content to your page (because a customer demanded it and cannot be convinced otherwise) than please use the Page Visibility API and Web Audio API, so you can silence/pause your audio once a customer is not viewing your page (the page is out of focus). --- But then again it is not possible on mobile browsers. You would need a user interaction to start audio playback *(like a play-button on the screen or an initial modal asking the user if he wants to "experience the full page by starting audio playback" or something like this)*. – Seika85 Jul 13 '16 at 06:52

1 Answers1

2

Most of the mobile browsers don't support audio autoplay to save mobile bandwidth on behalf of the user! The similar issue already discussed before, but i have something to share with you which may help you out.

Chrome does not allow applications to play HTML5 audio

after googlling little bit i found an article on codeproject which is really helpful in your case. here is the link.

Fix autoplay issue in mobile browser

i hope it will help you to come out from trouble, thanks.