0
  • I have a UIScrollView *myScrollView which has a UIView *videoView that contains a AVPlayerLayer *playerLayer(Actually a PBJVideoView if anyone is familiar).
  • The AVPlayerLayer is set to AVLayerVideoGravityResizeAspect.
  • myScrollView's delegate's - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView returns videoView.

So if I am looking at a landscape video on a portrait oriented iPhone, it fits the video so that the width matches the iPhone and there is black at the top and bottom.

As the zoomScale goes above 1.0 the video seems biased towards the right side. Like the anchorPoint is maybe (0.75,0.5) - even though it is (0.5,0.5). In other words it zooms into a point to the right of center. (Changing the anchor point doesn't seem to affect anything)

Is there something with the AVPlayerLayer that is causing this issue? I don't have the same problem with a UIImageView?

tettoffensive
  • 664
  • 7
  • 24

1 Answers1

0

Turns out this had little to do with AVPlayerLayer and more to do with UIScrollView's viewForZoomingInScrollView.

I had a UIImageView that is the "preview image" that shows while the video is downloading/loading, Both views were parented to the scroll view, then the image view was removed when the video player is ready. Because of this, the contentSize/contentOffset are off.

I was able to fix it by removing the videoView from the scroll view. Resetting the content offset and zoomScale to 1, then adding back in the video view.

tettoffensive
  • 664
  • 7
  • 24