0

I'm building an app using Sencha Touch and PhoneGap (aka Apache Cordova). I'm trying to play audio from an external domain with Sencha's Ext.Audio element (which creates an HTML5 audio element in the DOM) in response to a tap event.

In desktop versions of Chrome and Safari, this works fine. When I run the project as a "native" app on the iPhone, the audio will not play, but Xcode's console doesn't show any errors.

Using the same Ext.Audio.play() method, and the same audio file, but including the file in the app rather than loading it from an external server, it also plays.

Is this a cross-domain restriction? Does anyone know a way around it?

bjudson
  • 4,073
  • 3
  • 29
  • 46
  • Have you added the domain hosting the audio file to the white list in PhoneGap.plist (or Cordova.plist, depending on the version you are using)? Check this question for more details: http://stackoverflow.com/questions/10795628/error-whitelist-rejection-in-phonegap – raju-bitter Aug 20 '12 at 10:08
  • Yeah, I forgot to mention the domain is being used for other requests (which work fine), so it is whitelisted... – bjudson Aug 20 '12 at 14:14

1 Answers1

0

This appears to have been an HTTP header issue. Apparently the UIWebView is more finicky about that than desktop browsers. Not sure, but I changed the way the files were being served by the host, and it started working.

bjudson
  • 4,073
  • 3
  • 29
  • 46
  • Can you please explain what changes you've done? I've a similar issue. Thanks – Manuel Bitto Aug 22 '12 at 08:10
  • It is somewhat specific to my host, which is WebFaction. Originally, I was serving the files out of a mod_wsgi app, and I think that it was not setting the Content-Type header to indicate the media format. I moved the audio files to a static app, which I think is served by Nginx - but plain Apache would be fine. After that, it worked for me. – bjudson Aug 22 '12 at 15:36