0

There's not much to my question I guess. I'm just curious about how CocoaLibSpotify works with AVFoundation and if it's compatible with how Apple needs me to register for remote control events and to set the now playing info in MKNowPlayingInfoCenter.

Apple says to receive remote control events my app needs to "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.'" however, that's all the documentation I can find... Does playing a track with SPPlaybackManager meet this requirement? What is the requirement anyway?

Thanks for your help again.

Matt Egan
  • 809
  • 1
  • 10
  • 16

1 Answers1

2

Remote control events work fine with CocoaLibSpotify without any modifications to the library at all, but only on the device and not in the Simulator (including iOS7's Control Center).

Taking the Simple Player example, I made the following changes:

  • Changed Simple_PlayerAppDelegate to be a subclass of UIResponder.

  • Overrode canBecomeFirstResponder: to return YES.

  • Implemented remoteControlReceivedWithEvent:.

  • In the callback to the playTrack: call to CocoaLibSpotify, added:

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

These changes allowed Simple Player to receive remote control events when running on a device.

iKenndac
  • 18,730
  • 3
  • 35
  • 51
  • Thanks for your help Dan (this is Dan, isn't it?), I can't believe I sat for almost four or five hours scratching my head trying everything when it turns out the first thing I did would have worked had I tested on my device. This is literally stated nowhere in Apple's documentation.... Ugh. Thanks again though! – Matt Egan Oct 04 '13 at 13:43
  • @iKenndac Does the answer you've given apply to my question at: http://stackoverflow.com/questions/29655136/remotecontrolreceivedwithevent-not-called-when-streaming-audio-from-spotify ? I believe I have done what you are suggesting, but it does not work. CocoaLibSpotify is deprecated for iOS. I am using the iOS SDK. – JeffB6688 Apr 17 '15 at 19:34