IPhone ios4 - Replacing the iPod dock icon while playing a background audio stream

I figured out how I can play audio in the background on ios4, however I noticed that some apps also replace the iPod dock icon with their own app icon. (E.g. Last.fm and Spotify).

They can also use dock management tools to pause and resume their streams.

Does anyone know how to do this?

thanks

+7
iphone ios4 streaming avaudioplayer avplayer
source share
1 answer

Easily respond to remote control events. It also allows you to control your application with a headset.

In this case, you can call the viewDidLoad call:

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; [self becomeFirstResponder]; 

And you must answer both

 - (BOOL)canBecomeFirstResponder { return YES; } 

and

 - (void)remoteControlReceivedWithEvent:(UIEvent *)event { switch (event.subtype) { case UIEventSubtypeRemoteControlTogglePlayPause: if (audio.rate == 0.0) { [audio play]; } else { [audio pause]; } break; case UIEventSubtypeRemoteControlPlay: [audio play]; break; case UIEventSubtypeRemoteControlPause: [audio pause]; break; default: break; } } 
+18
source share

All Articles