Play audio in the Safari web app in iOS 8.1
Bever you mark this as "old", I've searched all www for a solution but can't find it.
I am making a WebApp that plays sound effects. I created an element var audio = new Audio()
and changed it src
to sound effect url. When I call the function audio.play()
, it starts playing a sound effect. In normal safari this works, but when I set apple-mobile-web-app-capable
in true
to the meta tag the WebApp crashes. I also tried hardcoded tag audio
to create a tag audio
using javascript and fill the div with an audio element and it didn't work.
var audio = new Audio;
function set(src){ audio.src = src; }
function play() { audio.play(); }
function pause() { audio.pause(); }
<button onClick="set('https://incompetech.com/music/royalty-free/mp3-royaltyfree/Thief%20in%20the%20Night.mp3')">Set sound</button>
<button onClick="play()">Play sound</button>
<button onClick="pause()">Pause sound</button><br /><br />
<b>Music:</b> "Thief in the Night" Kevin MacLeod (incompetech.com) Licensed under Creative Commons: By Attribution 3.0 License http://creativecommons.org/licenses/by/3.0/
Tnx in advance, Stefan
source to share
No one has answered this question yet