HTML5 audio on mobile: wait for playing
I use audio tag to play sound, here's code:
<audio autoplay="autoplay" controls="controls">
<source src="' + PathMp3 + '" type="audio/mp3" />
<source src="' + PathOgg + '" type="audio/ogg" />
Your browser does not support the audio element.
</audio>
Audio files are disposed on server. When I open html page on PC, audio starts to play immediately when I click on player.
However on mobile phone I tap on player and wait more than 30 seconds (sometimes 90secs!) before it starts to play. Very long delay.
Mobile internet isn't of course so fast as ordinary but it's 3G and the average size of audio file is 1.7 Mb, it isn't much.
Why it doesn't play audio while loadi开发者_JAVA百科ng? I need to start playing just after getting first bytes. How to do it?
Thanks
Your mobile browser will not play those files automatically, you have to tap on them to start playback.
This is a restriction put in place so random sites wont waste a 3g users bandwidth by playing huge audio files automatically.
<audio autoplay controls preload>
<source src="' + PathMp3 + '" type="audio/mpeg" />
<source src="' + PathOgg + '" type="audio/ogg" />
Your browser does not support the audio element.
</audio>
Have you tried this way?
By the way, as far as I know mp3 has a MIME-Type of "audio/mpeg".
精彩评论