devgeeks / ExampleHTML5AudioStreaming

Example project showing audio streaming using HTML5 Audio with PhoneGap on iOS - https://build.phonegap.com/apps/242993
164 stars 61 forks source link

Background audio #1

Closed shanebo closed 11 years ago

shanebo commented 11 years ago

Hello, thanks for this example. I'm trying to figure out how, if you did, you were able to get background audio to work. I understand all your js code but what did you do with phonegap to enable background audio? I used the same property/value as you did in your info.plist to no avail. Is there something else in your code I'm missing?

devgeeks commented 11 years ago

The important bit is in ExampleHTML5AudioStreaming-Info.plist

<key>UIBackgroundModes</key>
    <array>
        <string>audio</string>
    </array>

http://developer.apple.com/library/ios/#qa/qa1668/_index.html

If you have done this and it's still not working let me know. It certainly works for me.

I gather my example works in the background OK, just not your implementation?

shanebo commented 11 years ago

I can't seem to get background audio to work in your example in the simulator. Haven't tried the device yet though. That info.plist property is what I assumed it was and added it to my project also but it doesn't work on the simulator. Does it for you? Also, with this enabled do the audio controls in the multitask bar work? Does js logic hold up (like the progress counter, changing to other audio urls on complete) when switching to the background? My app requires pointing at different audio files once the other is complete. Will that logic go into pause mode in background? I ask because I'd hate to port my app from Titanium if I can't get all the way functionally with phonegap. Sorry to bother but there's not many of us audio devs on Ti or phonegap so you're a last resort :) Thanks for the help!

devgeeks commented 11 years ago

Hi,

OK, first up, the simulator can't do background audio. That will never work. You will have to test on a device.

However, you might also have problems with it going to the next track while in the background. Pretty sure you will be unable to execute arbitrary js while in the background :(

This is where Ti might have an advantage as it is compiled into native... not sure as I don't really know Ti that well.