dismiss AVPlayer after pressing done or video is finished

Hi,


i am trying to play different local videos on a button press inside a collection view cell.

My problem:


I start the first video by pressing the button and presenting the AVPlayer


playerViewController.player?.play


I can now rotate my device and the video is playing in landscape mode.

After I press done it goes back to the collectionview and I can choose the second video.


Now the second video plays, but when i go into landscape mode the first Video shows up

and there is no done or back button.


If I stay in portrait mode everything is fine..


Any ideas?


Thanks a lot.

Try both at same time:

               "yourAVPlayer".replaceCurrentItem(with: nil)
              "theURLoftheAVPlayer".removeAll()
dismiss AVPlayer after pressing done or video is finished
 
 
Q