我正在开发一个使用GoogleCast框架的iOS Obj-C应用程序。
我正在尝试通过MPNowPlayingInfoCenter使锁定屏幕控件工作
我已经为我的应用程序添加了正确的权限,以支持背景。
我像这样初始化cast设备:
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];
}
} 我开始相信,当媒体会话通过AVKit/ AVFoundation加载时,MPNowPlayingInfoCenter只提供对媒体会话的控制?我这样说对吗?
如果这是真的,我可能会用Chromecast上的play method创建一个NSInteger长的AVKit/ AVFoundation。然后强制AVPlayer隐藏和静默。然后我可以捕获媒体控件并重定向到Chromecast?
我想iOS上的Youtube应用是这样的吧?Netflix和Spotify在转换为chromecast时都不支持锁屏控件。
发布于 2017-07-11 01:17:19
我已经开发了一种在锁定屏幕中显示播放器控件的解决方案。我正在使用一些hack来工作,比如method_exchangeImplementations和一个静音来播放和模仿玩家。
我也在这篇文章中回复了Does google chromecast iOS SDK support lock screen controls?
到目前为止,它工作得还不错,但可能还需要改进。
https://stackoverflow.com/questions/42366099
复制相似问题