在基本音频AVPlayer
实例中,我们正在播放HLS流并设置正在播放信息(已成功),但无法访问正在设置的MPNowPlayingInfoCenter
的属性。< / p>
我们category
的{{1}}和active
状态以及receiving remote control events也没有问题。
AVAudioSession
NSMutableDictionary *properties = [[NSMutableDictionary alloc] init];
[properties setObject:title forKey:MPMediaItemPropertyTitle];
// Set several other properties
MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter];
[center setNowPlayingInfo:properties];
// Works! The lock screen successfully shows the title and other properties
NSLog("%@", [center nowPlayingInfo]);
打印一个非常默认的字典,其中只包含NSLog
MPNowPlayingInfoPropertyPlaybackRate
- 这在日志期间播放音频时无论如何都不准确。
我们希望retrieve the currently-set dictionary of properties,更新一些,然后重新设置它们(适用于专辑封面更新,播放/暂停时间等)。我们缺少什么?
答案 0 :(得分:0)
尝试以下方法来检索当前属性;
NSMutableDictionary *playInfo = [NSMutableDictionary dictionaryWithDictionary:[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo] ;
并设置/更新属性如下;
[playInfo setObject:[NSNumber numberWithFloat: 1.0f] forKey:MPNowPlayingInfoPropertyPlaybackRate];
[playInfo setObject:[NSNumber numberWithDouble:songDuration] forKey:MPMediaItemPropertyPlaybackDuration];
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = playInfo;