具有 AVPlayerLayers 的多个 AVPlayer 消失第二次推送视图控制器
我有一个带有四 (4) 个 AVPlayer 的视图控制器(带有 AVPlayerLayers,如 APPLE 示例)。
如果我弹出此视图控制器并推送相同类型的新实例。我无法在一两个 AVPlayer 中播放视频。没有错误,代码运行良好,AVPlayerLayers 还说它有一个 superLayer。
最奇怪的是,如果我按下主页按钮,回到跳板并进入应用程序,所有视频播放器(如魔术)都会开始播放。就像它重新渲染视图树什么的。
有什么提示或线索吗?
附言。我使用 loadValuesAsynchronouslyForKeys 等待资产准备就绪。
I have a viewcontroller with four (4) AVPlayers (with AVPlayerLayers like APPLE example).
If I pop this viewcontroller and the push a new instance of the same type. I'm not able to play video in one or two AVPlayers. No errors and code runs fine, AVPlayerLayers also says it has a superLayer.
And to the most strange thing if I push home button, coming back to springboard and the enter the app all video players like magic start playing. It's like it rerender the view tree or something.
Any hints or clues?
PS. I wait for assets to be ready using loadValuesAsynchronouslyForKeys.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们也有类似的问题。以下答案导致解决方案:
AVplayer 在 2-3 次后未显示在 ScrollView 中
你必须调用: [AVPlayer ReplaceCurrentItemWithPlayerItem:nil];当你的视图控制器被卸载时。这可能很棘手,因为您可能添加了观察者或使用了 addBoundaryTimeObserverForTimes:queue:usingBlock:
另外,您在再次检查 superlayer 时必须小心:在确定视图是否仍附加到视图层次结构时,更好地检查 uiview.window 。
你的
菲尔
We had a similar problem. Following answer lead to the solution:
AVplayer not showing in ScrollView after 2-3 times
You have to call: [AVPlayer replaceCurrentItemWithPlayerItem:nil]; when your viewcontroller gets unloaded. This might be tricky as you might have added an observer or used addBoundaryTimeObserverForTimes:queue:usingBlock:
Also you have to be careful when checking agaings superlayer: Better check against uiview.window when determing whether your view is still attached to the view hierarchy.
yours
phil