10

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.

Wim Vanhenden
  • 841
  • 2
  • 12
  • 18
  • 1
    I'm wanting to do the same exact thing - remove the player from memory, completely. It seems that the MediaServerD daemon is keeping my video stored in memory and eating up a lot of memory in the process. I was wondering if you can point me the articles you read. – ArtSabintsev Jan 28 '13 at 06:35
  • Did you find a solution? – Roi Mulia Jan 31 '19 at 11:44
  • Did you manage to find a solution? I'm still searching for it – StackGU Oct 28 '20 at 12:46

0 Answers0