iOS - UIEventTypeRemoteControl events not received

前端 未结 1 522
梦毁少年i
梦毁少年i 2020-12-18 08:18

I have this in the AppDelegate (didFinishLaunching):

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

I tried handlin

相关标签:
1条回答
  • 2020-12-18 09:20

    ok, a few more hours of my life into black hole of Apple. Turns out that you can only capture remote control events after you have played audio of some kind using the AVAudioPlayer, or if you play a video file that has audio. This is not documented anywhere here.

    So in my case I have to play a dummy silent audio file first before I try to capture remote control events. Hope this helps someone down the line.

    (Update) Please note that the updated documentation now states the following:

    To receive remote control events, your app must do three things:

    • Be the first responder. The view or view controller that presents the multimedia content must be the first responder.
    • Turn on the delivery of remote control events. Your app must explicitly request to begin receiving remote control events.
    • Begin playing audio. Your app must be the “Now Playing” app. Restated, even if your app is the first responder and you have turned on event delivery, your app does not receive remote control events until it begins playing audio.
    0 讨论(0)
提交回复
热议问题