iOS 4: Remote controls for background audio

后端 未结 7 1387

I\'m currently attempting to set up background audio for an app I\'m developing for iOS 4. The app doesn\'t have a dedicated music player viewController, howeve

7条回答
  •  悲&欢浪女
    2020-12-07 18:42

    I found a couple of solutions to receiving global remote control events on the Apple Developer Forums after a bit of searching.

    One way is to subclass UIWindow and override its remoteControlReceivedWithEvent:.

    The second, perhaps nicer way is to subclass UIApplication and override sendEvent:. That way, you can intercept all the remote control events and handle them there globally, and not have any other responders handle them later in the responder chain.

    - (void)sendEvent:(UIEvent *)event {
         if (event.type == UIEventTypeRemoteControl) {
              // Handle event
         }
         else
              [super sendEvent:event];
    }
    

提交回复
热议问题