AVplayer完全删除视频内存不足

发布于 2025-01-01 04:16:02 字数 599 浏览 5 评论 0原文

我知道 Stackoverflow 上有一些关于这个问题的提示,但我还没有找到对我的问题非常满意的答案。

我想从内存中完全删除 AVPlayerLayer 类中使用 AVPlayer 播放的视频。我读过您实际上不允许调用包含 AVPlayerLayer 的类的 dealloc 。但即使我这样做,视频仍然保留在内存中(cfr 声音不会停止播放)。

有些人暗示您应该暂停播放器,或者只是加载一个新视频,但我希望它消失...

我需要这个,因为旋转设备时,我希望视频从内存中踢出,并加载一个新视频新的方向。我需要完全销毁视频,因为它所在的父视图也需要被销毁。

结构

这是我的UIView 的 -> UI滚动视图 -> UIviewWithPlayer -> AVPlayerLayer

在 UIscrollView 中,我在 UIViewWithPlayer 上调用release和removefromsuperview。在 UIviewWithPlayer 中,我在 AVPlayerLayer 上调用release和removefromsuperview。但这似乎不起作用。

预先非常感谢您的帮助。

I know there have been a few hints on Stackoverflow about this issue but I haven't found a very satisfying answer to my problem.

I want to completely remove a video playing with AVPlayer in an AVPlayerLayer class from memory. I have read your are actually not allowed to call dealloc of the class containing the AVPlayerLayer. But even when I do so, the video remains in memory (cfr the sound does not stop playing).

Some people hint that you should pause the player, or just load in a new video, but I want it gone...

I need this because when rotating the device, I want the video kicked out of memory and a new video loaded in for the new orientation. I need to destroy the video completely because the parent view it is in also needs to be destroyed.

This is the structure I have

UIView
-> UIScrollView
-> UIviewWithPlayer
->AVPlayerLayer

In UIscrollView I call release and removefromsuperview on UIViewWithPlayer. In UIviewWithPlayer I call release and removefromsuperview on AVPlayerLayer. But that does not seem to work.

Thank you very much in advance for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文