【发布时间】:2017-02-21 11:30:37
【问题描述】:
我正在开发一个使用 GoogleCast 框架的 iOS Obj-C 应用程序。
我正在尝试通过MPNowPlayingInfoCenter 使锁屏控件工作
我已为我的应用添加了正确的权限以支持后台处理。
我正在像这样初始化投射设备:
self.chromeCastDeviceManager = [[GCKDeviceManager alloc] initWithDevice:self.selectedChromeCastDevice clientPackageName:[info objectForKey:@"CFBundleIdentifier"] ignoreAppStateNotifications:YES];
当我在接收器上启动媒体时,当我获得成功的播放响应时,我会尝试初始化 MPNowPlayingInfoCenter。
NSInteger result = [_castControlChannel play];
if (!result) {
//launch has worked
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");
if (playingInfoCenter) {
NSDictionary *songInfo = [NSDictionary dictionaryWithObjectsAndKeys:
@"Test artist", MPMediaItemPropertyArtist,
@"Test title", MPMediaItemPropertyTitle,
@"Test Album", MPMediaItemPropertyAlbumTitle,
nil];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];
}
}
我开始相信MPNowPlayingInfoCenter 仅在通过AVKit/ AVFoundation 加载媒体会话时提供控制?我这样说对吗?
如果这是真的,我可能会在 Chromecast 上创建一个带有 play method 的长的 AVKit/ AVFoundation NSInteger。然后强制 AVPlayer 隐藏和静音。然后我可以捕捉媒体控件并重定向到 Chromecast?
我假设 iOS 上的 Youtube 应用程序是这样做的? Netflix 和 Spotify 在投射到 chromecast 时都不支持锁屏控制。
【问题讨论】:
-
Spotify也有这个功能,我很想知道它有什么诀窍,这件事有什么新进展吗?
标签: ios objective-c avfoundation google-cast mpnowplayinginfocenter