Lock Screen iPod Controls Not Working With Spotify Music Player

大兔子大兔子 提交于 2019-12-05 06:04:18

I believe I ran into this in the past. If I remember correctly I added in the

-(void)remoteControlReceivedWithEvent:(UIEvent *) event { ... }

as well as

- (BOOL) canBecomeFirstResponder { return YES; }

to the app delegate (This is also where my audio controller lived). I was having having the issue where the UIViewControllers were not alive during the time I wanted to catch the UIEventTypeRemoteControl notifications.

Give that a try and see if that helps.

After further investigation, I have found that if include the following code when my app enters the background and when the remote control events are received, the iPod controls do not disappear.

// Set up info center to display album artwork within ipod controls (needed for spotify)
MPMediaItemArtwork *ipodControlArtwork = [[MPMediaItemArtwork alloc]initWithImage:artworkImage];
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = [NSDictionary dictionaryWithObjectsAndKeys:nowPlayingTitle, MPMediaItemPropertyTitle,
                                                         nowPlayingArtist, MPMediaItemPropertyArtist, ipodControlArtwork, MPMediaItemPropertyArtwork,  [NSNumber numberWithDouble:0.0], MPNowPlayingInfoPropertyPlaybackRate, nil];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!