我在我的应用程序中使用AVQueuePlayer播放一些媒体。我试图使用MPNowPlayingInfoCenter显示当前的回放状态时,应用程序是背景。我的问题是播放按钮总是显示,即使当媒体播放。我通过以下代码设置现在播放的信息:
NSDictionary *songInfo = @{
MPMediaItemPropertyTitle: title,
MPMediaItemPropertyArtist: artist,
MPMediaItemPropertyAlbumTitle: album,
MPMediaItemPropertyPlaybackDuration: duration,
MPNowPlayingInfoPropertyPlaybackRate: @(1.0f),
MPNowPlayingInfoPropertyElapsedPlaybackTime: @(0.0f)
};
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];正如您从下面的屏幕截图中看到的,显示了“播放”按钮,我希望在这里看到暂停按钮。

如果与此相关,我将AVAudioSession类别设置为AVAudioSessionCategoryPlayback。
NSError *sessionError = nil;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback
error:&sessionError];
[[AVAudioSession sharedInstance] setActive: YES error: NULL];发布于 2014-12-15 11:18:24
也许有点违背直觉,但为了设置play按钮状态,并启动经过的时间增量,需要执行以下操作:
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];https://stackoverflow.com/questions/27482641
复制相似问题