3

I have a viewcontroller with four (4) AVPlayers (with AVPlayerLayers like APPLE example).

If I pop this viewcontroller and the push a new instance of the same type. I'm not able to play video in one or two AVPlayers. No errors and code runs fine, AVPlayerLayers also says it has a superLayer.

And to the most strange thing if I push home button, coming back to springboard and the enter the app all video players like magic start playing. It's like it rerender the view tree or something.

Any hints or clues?

PS. I wait for assets to be ready using loadValuesAsynchronouslyForKeys.

Max
  • 764
  • 7
  • 14
  • I experienced the same problem too where if the rootViewController has an AVPlayerLayer (w/ AVPlayers), then I push another viewController, when I pop back to the rootVC, the video is scrunched up regardless of the videoGravity property. Following the solution below solved my problem. – John K. Chow May 18 '14 at 00:49

1 Answers1

3

We had a similar problem. Following answer lead to the solution: AVplayer not showing in ScrollView after 2-3 times

You have to call: [AVPlayer replaceCurrentItemWithPlayerItem:nil]; when your viewcontroller gets unloaded. This might be tricky as you might have added an observer or used addBoundaryTimeObserverForTimes:queue:usingBlock:

Also you have to be careful when checking agaings superlayer: Better check against uiview.window when determing whether your view is still attached to the view hierarchy.

yours phil

Community
  • 1
  • 1
hellphil
  • 415
  • 6
  • 10