2

My app plays audio streams, it works fine for all cases such as background etc. I am using AudioToolbox.framework and MediaPlayer.framework to play the audio, my query is when the app starts playing audio i would want the indicator on the status bar to be shown as it does for the default iPod player.

Can anyone guide me on how to display the play indication icon on the status bar as soon as my app starts playing audio and disappears when its paused/ stopped or terminated.

1 Answers1

0

As is described by iHemantk:

You just have to register for remote control events and icon will show up:

https://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/Remote-ControlEvents/Remote-ControlEvents.html#//apple_ref/doc/uid/TP40009541-CH7-SW3

they added this in 4.0... works well. whoever is first responder now controls the icon... just won't work for anything pre-iOS4: put the following in your -viewDidAppear method:

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

[self becomeFirstResponder];


and include this method in the code:


- (BOOL) canBecomeFirstResponder {
    return YES;
}

this goes in `-dealloc`:


[[UIApplication sharedApplication] endReceivingRemoteControlEvents];

and while not necessary, you may want to include this in the -viewWillDisappear:

[self resignFirstResponder];
Brad Larson
  • 170,088
  • 45
  • 397
  • 571
One Man Crew
  • 9,420
  • 2
  • 42
  • 51