问题描述
我有一个内置 React Native 的 iOS 应用程序,它使用 react-native-video 包播放视频内容并允许使用 AirPlay。当应用程序进入后台(按主页按钮、锁定屏幕或打开向下滑动菜单)时,视频将暂停,您必须从控制中心或锁定屏幕媒体控件恢复播放。我知道这是 AVPlayer 的预期行为,我正在尝试从 Apple documentation 实施以下解决方案:
删除/恢复 AVPlayerLayer 及其关联的 AVPlayer
所提供的代码片段使用 Swift,我似乎无法在我的 AppDelegate.m 文件中使用 Objective-C 找到实现此目的的完整示例。
/* Remove the AVPlayerLayer from its associated AVPlayer
once the app is in the background. */
- (void)applicationDidEnterBackground:(UIApplication *)application {
MyPlayerLayerView *playerView = <#Get your player view#>;
[[playerView playerLayer] setPlayer:nil]; // remove the player
}
/* Restore the AVPlayer when the app is active again. */
- (void)applicationDidBecomeActive:(UIApplication *)application {
MyPlayerLayerView *playerView = <#Get your player view#>;
[[playerView playerLayer] setPlayer:_player]; // restore the player
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)