AVplayer completely deletes video from memory

I know that this issue had some Stackoverflow tips, but I did not find a very satisfactory answer to my problem.

I want to completely delete video from AVPlayer in class AVPlayerLayer from memory. I read that it is actually not allowed to call the dealloc of a class containing AVPlayerLayer. But even when I do this, the video remains in memory (cfr sound does not stop playing).

Some people are hinting that you should pause the player or just upload a new video, but I want it to disappear ...

I need this because when you rotate the device, I want the video to go out of memory and the new video to load for a new orientation. I need to completely destroy the video, as its parent view also needs to be destroyed.

This is the structure in which I

UIView -> UIScrollView -> UIviewWithPlayer -> AVPlayerLayer

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

Thanks in advance for your help.

+6
source share

Source: https://habr.com/ru/post/907208/


All Articles