在一个基本的音频AVPlayer实例中,我们正在播放HLS流并设置正在播放的信息(成功),但无法访问正在设置的MPNowPlayingInfoCenter的属性。
我们的AVAudioSession和receiving remote control events的category和active状态也没有问题。
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打印一个非常默认的字典,其中只包含0的MPNowPlayingInfoPropertyPlaybackRate -这是不准确的,因为在日志期间正在播放音频。
我们想要retrieve the currently-set dictionary of properties,更新一些,并再次设置它们(对于像专辑画面更新,播放/暂停计时等)。我们遗漏了什么?
发布于 2014-04-29 05:25:36
尝试执行以下操作以检索当前属性;
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;https://stackoverflow.com/questions/23345669
复制相似问题