Hi guys,
Im using AVPlayer for the audio in my app. I have it playing audio, setting
up its audio session correctly (I think, the play icon appears in the status
bar when I play audio tracks within my app, and my app icon appears beside
the player transport controls in the multitasking dock). However, I cannot
get it to continue playing in the background when I press the Home button.
The music just fades out and stops.
I have the following key in my info.plist:
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
In my class that handles playback, I have:
AVAudioSession audioSession =
AVAudioSession.SharedInstance();
NSError error;
audioSession.SetCategory(AVAudioSession.CategoryPlayback.ToString(),out
error);
audioSession.SetActive(true,out error);
UIApplication.SharedApplication.BeginReceivingRemoteControlEvents();
int taskID = 0;
taskID =
UIApplication.SharedApplication.BeginBackgroundTask(delegate
{
if(taskID !=0)
{
UIApplication.SharedApplication.EndBackgroundTask(taskID);
taskID = 0;
}
});
PlaylistManager = new ApolloPlaylistManager();
AudioPlayer = new AVPlayer();
Not sure if I need that BeginBackgroundTask part, but it doesn't work if its
in or out. Any ideas?!
--
View this message in context:
http://monotouch.2284126.n4.nabble.com/Background-Audio-with-AVPlayer-tp3807564p3807564.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch