Website HTML 5 Audio Autoplay

醉酒当歌 提交于 2020-01-16 05:22:31

问题


I have an intranet thats basically a web page on the amazon fire browser, and i want an audio file to autoplay when the page loads...

<audio controls autoplay>
 <source src="alarm.ogg" type="audio/ogg">
 <source src="alarm.mp3" type="audio/mpeg">
 Your browser does not support the audio element.
</audio>

This works fine on the desktop browsers, Chrome, Safari, etc. However, on the fire tablet (and my iPhone) the audio element is there but you have to press play, it doesn't autoplay.

Any ideas how to make this work?

Thanks


回答1:


From howler.js documentation:

By default, audio on iOS, Android, etc is locked until a sound is played within a user interaction, and then it plays normally the rest of the page session (Apple documentation). The default behavior of howler.js is to attempt to silently unlock audio playback by playing an empty buffer on the first touchend event.



来源:https://stackoverflow.com/questions/36331492/website-html-5-audio-autoplay

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!