I am working on an iPhone iOS4 application that plays music from the user's iPod library. I also want to track which songs are played and able to change this song randomly, even in the background. That's why I have set up using the music player:
[Self-set music player: [MP music player controller iPod music player]]; Now, I want to continue to run this application in the background and play music, so I set:
Expected background mode: app Audio runs The problem I am facing is that whenever it is transferred in the background, my app loses control (when app switches are called, applicationDidEnterBackground is). Because I am using iPodMusicPlayer, the music keeps on, but my app does not have control and so can not track or change the song.
Now, the Apple documentation says that your application should continue to execute in the background using the required background mode tag, but mine is not what I am using MPMusicPlayer? Is there any way to get around this? any idea?
PS I am also trying to get remote lock and multitasking iPod controller to work with my application. I'm using the code given below, but never called the remote control, RidgewedWithweit! Does it work with MPMusicPlayer? I've only seen it with the aviideo player.
- (zero) Remote control resuscitation event: (UIIEvent *) Event {NSLog (@ "Remote Control RecoveryWidth Event"); Switch (event.subtype) {case UIEventSubtypeRemoteControlTogglePausePause: NSLog (@ "Stop Play"); break; Case UIEventSubtypeRemoteControlNextTrack: NSLog (@ "Next"); break; Default: Break; }} - (BOOL) can first responder {nslog (@ "canback first responder"); Yes come back } - (Zero) VisualElementsPower: (BUSE) animated ([UIApplication sharedApplication] remote control events starting]; [self-made first responder];}
Your iPhone app will not run in the background when you are using the MPMusicPlayerController , which will also prevent you from receiving remote control events. / P>
If you want to play audio from iPod library and your app is running in the background, you can run -level AVPlayer class.
Comments
Post a Comment