首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS - Chromecast与MPNowPlayingInfoCenter集成,提供锁屏控制

iOS - Chromecast与MPNowPlayingInfoCenter集成,提供锁屏控制
EN

Stack Overflow用户
提问于 2017-02-21 19:30:37
回答 1查看 739关注 0票数 2

我正在开发一个使用GoogleCast框架的iOS Obj-C应用程序。

我正在尝试通过MPNowPlayingInfoCenter使锁定屏幕控件工作

我已经为我的应用程序添加了正确的权限,以支持背景。

我像这样初始化cast设备:

self.chromeCastDeviceManager = [[GCKDeviceManager alloc] initWithDevice:self.selectedChromeCastDevice clientPackageName:[info objectForKey:@"CFBundleIdentifier"] ignoreAppStateNotifications:YES];

当我在接收器上启动媒体时,当我得到一个成功的播放响应时,我会尝试初始化MPNowPlayingInfoCenter

代码语言:javascript
复制
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时都不支持锁屏控件。

EN

回答 1

Stack Overflow用户

发布于 2017-07-11 01:17:19

我已经开发了一种在锁定屏幕中显示播放器控件的解决方案。我正在使用一些hack来工作,比如method_exchangeImplementations和一个静音来播放和模仿玩家。

我也在这篇文章中回复了Does google chromecast iOS SDK support lock screen controls?

到目前为止,它工作得还不错,但可能还需要改进。

看一看https://github.com/peantunes/google-cast-ios-lock-screen

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42366099

复制
相关文章

相似问题

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