我已经启动并运行了MPNowPlayingInfoCenter,但是仍然存在一个问题。
无论我的播放器实际状态如何,MPNowPlayingInfoCenter始终处于“播放”状态并显示暂停按钮。当按下它会触发暂停事件。
当我的播放器更改状态(例如暂停)时,我会通过MPNowPlayingInfoPropertyPlaybackRate键更新MPNowPlayingInfoCenter。
还有其他方法可以将MPNowPlayingInfoCenter状态设置为暂停吗?
任何提示表示赞赏!
最佳答案
试试这个:
NSMutableDictionary *currentlyPlayingTrackInfo = [NSMutableDictionary dictionaryWithCapacity:7];
currentlyPlayingTrackInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = @((Float64)[player currentTime]);
if (!SYSTEM_VERSION_OF_DEVICE_LESS_THAN(@"7.0"))
{
currentlyPlayingTrackInfo[MPNowPlayingInfoPropertyPlaybackRate] = [NSNumber numberWithDouble:_isHere == NO?1:0];
}
else
{
currentlyPlayingTrackInfo[MPNowPlayingInfoPropertyPlaybackRate] = [NSNumber numberWithDouble:1];
}
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:currentlyPlayingTrackInfo];
关于ios - MPNowPlayingInfoCenter始终处于播放状态,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23583233/