I'm currently developing a video player for streamed-content using the AVPlayer Framework. I stumbled across the AVPlayerLayer's VideoGravity String-Property which would allow me to set the players Scaling/Resizing Mode to different values.
In order to provide the user with the scaling-features known from the default player, I've set up a method that would execute the following code:
AVPlayerLayer *layer = (AVPlayerLayer *)[self.videoContainer layer];
if([layer.videoGravity isEqualToString:AVLayerVideoGravityResizeAspect])
layer.videoGravity = AVLayerVideoGravityResizeAspectFill;
else
layer.videoGravity = AVLayerVideoGravityResizeAspect;
This works very well in the Simulator, but somehow not on my iPad 2 with iOS 5.0.1 installed.
Has anyone experienced similar issues? Is this a known iOS Bug with 5.0.1? Is there a better approach of implementing scaling / resizing with AVPlayerLayer?
Any ideas/tips/help and recommendations are greatly appreciated,
Thanks,
Sam
Setting the bounds will internally setNeedsLayout
. You must call this your self if you only change the gravity. A call to setNeedsDisplay
to force a re-draw couldn't hurt either, although I imagine AVPlayerLayer is updating the layer contents so frequently that it won't matter.
EDIT: Your name is twice as good as mine!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With