0

I have an issue where when user is playing a video , while video is being player, he uses siri to search for a different movie, which will load its corresponding movie details page and then select to play that movie, which deeplinks to your app which is playing a movie, when i play a new selected movie and dismiss avplayer and avplayercontroller, audio from previous video still continues to play. somehow avplayer is not cleared although i clear all subviews from window and initialize its super view controller class again. I am cluless what can i do erase older instance of avplayer. Let me know if anyone has any suggestions or faced similar issue.

1 Answer 1

0

A few suggestions:

  1. Are you subclassing AVPlayerViewController? If so, that's a bad idea. The API docs specifically say not to do that.
  2. Add a deinit function. If it's not being called when the old AVPlayer is dismissed, you know you have a retention problem. This is often caused by registering for notifications or boundary time observers.
  3. If you view controller has a reference to the AVPlayer object, you might try overriding the viewDidDisappear function to call player.pause() and then setting the player reference first to a new instance of AVPlayer() then to nil. Not sure why this helps, but sometimes it does.

Definitely implement #2 above. If deinit is not getting called, you most certainly have an issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.