1

I'm trying to play sounds on an iPad web app. Using jquery mobile and iOS 6.1. I'm aware of autoplay limitations on iOS therefore I'm starting the audio via a click (function). It works fine in Safari browser on iPad. But when I access the very same page as web app in full screen (added to home screen) it doesn't play. I would have thought that it's just the very same Safari just in fullscreen. Apparently that is not the case, there seem to be extra restrictions on the web app.

Why would the html5 audio play in iPad Safari browser but not via iPad web app? Are there more restriction I need to be aware of in browser vs web app?

Example code I used:

html: <audio id="audio" src="/audio/test.mp3"></audio>
script:
$(document).on("pageinit", function () {
        var audio = document.getElementById('audio');
        $("#playGame").on("click", function (event, ui) {

            audio.play();
        });
    });
Lars
  • 120
  • 2
  • 10
  • Only thing that springs to mind is the relative link. I would try and either (1) make the audio `src` absolute, or (2) [cache the file using the browser localStorage](http://stackoverflow.com/questions/1612116/html5-local-storage-of-audio-element-source-is-it-possible). – Labu Feb 17 '13 at 09:25
  • @WillemLabu Changing to absolute ref didn't do the trick. Sounds like I might need to look into audio encoding [link] (http://stackoverflow.com/questions/1612116/html5-local-storage-of-audio-element-source-is-it-possible). I'll check that out. – Lars Feb 18 '13 at 15:47
  • Good luck with that. :{D – Labu Feb 20 '13 at 09:10

1 Answers1

0

I struggled with the same thing. On Safari and Chrome: no problem with playing audio. Stopping, pausing, playing, everything works.

But the same in a web app: no audio.

Turned out to be a simple thing. I removed this line:

<meta name="apple-mobile-web-app-capable" content="yes">

And I have audio playing! It's not a real web app anymore; the URL box and Safari controls are displayed.... but I needed the audio to work (web player) so this is good enough for me...

Fleskalebas
  • 71
  • 1
  • 7