0

We have a Phonegap app (iPhone only currently) which uses both the HTML5 Audio tag (for streaming) and the Media object (for playing locally stored mp3s). They both provide web-links to the itunes store.

It used to be the case (with the Media object at least) that the audio would continue playing even when the app was backgrounded due to another app being launched, or an itunes link being loaded. This was achieved simply by adding "audio" to the UIBackgroundModes, in the project config. (info.plist)

I understand that this has changed with the advent of iOS6: UIWebView: HTML5 audio pauses in iOS 6 when app enters background

This fixed the problem for the HTML5 audio (i.e. the streaming audio continues to play when I launch itunes with a web-link) but for the Media object - the audio still cuts-out when I follow an itunes link). Curiously, the audio doesn't cut-out when I use itms-apps:// instead of http:// but then it launches the app-store rather than itunes. In other words, itunes is the only app which causes the audio to cut-out, but only when its played from the Media object.

Does anyone know why launching iTunes might be cutting out the audio produced by the Media object, whilst other apps don't?

Community
  • 1
  • 1
jacker
  • 11
  • 3

1 Answers1

0

Seems like the problem only occurs when iTunes is launched via the Cordova WebView, i.e. using one of the following:

url = 'https://itunes.apple.com/gb/album/elliphant-ep/id590384846'

1. window.location.href = url
2. window.open(url);
3. window.open(url , '_self');

The solution is to get it to use another app to launch itunes:

window.open(url , '_system');

will open the url in the system browser, the system intercepts the itunes link and itunes is launched via the system browser.

w = window.open(url, '_blank');

will force the url to launch in the InAppBrowser, again the system intercepts the itunes link and itunes is launched via the InAppBrowser. This is an uglier solution, as the InAppBrowser doesn't close automatically, and when the user returns to the app the InAppBrowser will still be visible. To close it one needs to call w.close()

jacker
  • 11
  • 3