-1

I crate audio tag, and use 'autoplay' to start audio. On Descktop work well, but not work on mobile device: ipad, winphon, android 4+...

<audio id="myAudio"  onerror="toConvert()" class="full-width"  src="{{ direct_link }}" controls autoplay  onpause="$('#play_ico').show()"   onplaying="$('#play_ico').hide()"></audio>

I tried using jquery, js, canplay, canplaythrougt and many other methods from web, but they dont work in mobile and working well on descktop....

How can I start playing audio on mobile device?

I use: goRatchet, Bootstrap and Django.

1 Answers1

0

In Safari on iOS (for all devices, including iPad), where the user may be on a cellular network and be charged per data unit, preload and autoplay are disabled. No data is loaded until the user initiates it. This means the JavaScript play() and load() methods are also inactive until the user initiates playback, unless the play() or load() method is triggered by user action. In other words, a user-initiated Play button works, but an onLoad="play()" event does not.

This plays the movie: <input type="button" value="Play" onclick="document.myMovie.play()">

This does nothing on iOS: <body onload="document.myMovie.play()">

You can ref: Playing Sounds with the Web Audio API.

anonystick
  • 362
  • 1
  • 9
  • How m.youtube.com start play video automaticly? – AlexKohankin Mar 07 '17 at 11:44
  • @user3080031: Yes, i will show you a demo. You can check it on iphone. [demo on iphone about playauto](http://bfred-it.github.io/iphone-inline-video/demo/). Hope you can check debug and see attribute video. If failed, you can contact via skype: tungtrum17 , i will help you. good luck. – anonystick Mar 08 '17 at 03:10
  • I try to play mp3 sound automaticly on my page, and it work if i only start it whit "muted" attribut. – AlexKohankin Mar 11 '17 at 11:38
  • On Windows Phone 8.1 "autoplay" working well. On windows phone 10 (al brousers) not work – AlexKohankin Mar 11 '17 at 12:08