How to trigger HTML5 play sound on Mobile Safari
- <audio id="play" src="sound/some-sound.ogg" preload="auto"></audio>
- <button id="btn" value="play sound"></button>
- $(function() {
- $('#btn').on('click', function() {
- $('#play').trigger('play');
-
- setTimeout(function() {
- $('#play').trigger('play');
- }, 3000);
- });
- });
This code works for most mobile browser but Apple Safari, few mobile browsers does not support play html5 format sound
without click, therefore they will only hear the sound once, is there any way to overcome it.