锁屏播放/暂停控件未更改

时间:2019-01-25 16:37:40

标签: ios objective-c mpnowplayinginfocenter mpremotecommandcenter

我想在应用中点击“播放/暂停”时更改锁定屏幕上的“播放/暂停”按钮图标。

当我从锁定屏幕上点击播放/暂停时,我会在应用程序中接收它并更新视图,但是当我在应用程序中点击它时,它不会在锁定屏幕上更新。

我正试图通过这种方式做到这一点:

NSMutableDictionary *currentlyPlayingTrackInfoDict = [[NSMutableDictionary alloc] initWithCapacity:3];

[currentlyPlayingTrackInfoDict setObject:[NSNumber numberWithFloat:[[AudioPlaybackManager shared] isPlaying] ? 1.0f : 0.0f] forKey:MPNowPlayingInfoPropertyPlaybackRate];
[currentlyPlayingTrackInfoDict setObject:[NSNumber numberWithFloat:10.0] forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime];
[currentlyPlayingTrackInfoDict setObject:[NSNumber numberWithFloat:100.0] forKey:MPMediaItemPropertyPlaybackDuration];

[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:currentlyPlayingTrackInfoDict];

但这只会影响搜索栏。

有人遇到过类似的问题吗?我还应该设置其他内容吗?

0 个答案:

没有答案
相关问题