首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >检索/更新单个MPNowPlayingInfoCenter属性

检索/更新单个MPNowPlayingInfoCenter属性
EN

Stack Overflow用户
提问于 2014-04-28 23:54:04
回答 1查看 1.8K关注 0票数 0

在一个基本的音频AVPlayer实例中,我们正在播放HLS流并设置正在播放的信息(成功),但无法访问正在设置的MPNowPlayingInfoCenter的属性。

我们的AVAudioSessionreceiving remote control eventscategoryactive状态也没有问题。

代码语言:javascript
复制
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打印一个非常默认的字典,其中只包含0MPNowPlayingInfoPropertyPlaybackRate -这是不准确的,因为在日志期间正在播放音频。

我们想要retrieve the currently-set dictionary of properties,更新一些,并再次设置它们(对于像专辑画面更新,播放/暂停计时等)。我们遗漏了什么?

EN

回答 1

Stack Overflow用户

发布于 2014-04-29 05:25:36

尝试执行以下操作以检索当前属性;

代码语言:javascript
复制
 NSMutableDictionary *playInfo = [NSMutableDictionary dictionaryWithDictionary:[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo] ;

并按如下方式设置/更新属性;

代码语言:javascript
复制
[playInfo setObject:[NSNumber numberWithFloat: 1.0f] forKey:MPNowPlayingInfoPropertyPlaybackRate];
[playInfo setObject:[NSNumber numberWithDouble:songDuration] forKey:MPMediaItemPropertyPlaybackDuration];

[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = playInfo;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23345669

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档