In my application, I created a custom video player using AVPlayer. This works great and no problem. However, I allow the gravity of the video to be AVPlayerchanged by double-clicking.
When it is changed to AVPlayerGravityResizeAspect, the video is centered in the middle. Is there a way to make a video image of the same size (resize, do not resize the fill), but move it to the bottom or top AVPlayer?
- (IBAction)zoomTapped:(id)sender {
if (self.player.status == AVPlayerStatusReadyToPlay) {
if ([((AVPlayerLayer *)[self.playerView layer]).videoGravity isEqualToString : AVLayerVideoGravityResizeAspect]) {
[self.zoomButton setImage:[UIImage imageNamed:@"zoom-out.png"] forState:UIControlStateNormal];
((AVPlayerLayer *)[self.playerView layer]).videoGravity = AVLayerVideoGravityResizeAspectFill;
}
else {
[self.zoomButton setImage:[UIImage imageNamed:@"zoom-in.png"] forState:UIControlStateNormal];
((AVPlayerLayer *)[self.playerView layer]).videoGravity = AVLayerVideoGravityResizeAspect;
((AVPlayerLayer *)[self.playerView layer]).bounds = ((AVPlayerLayer *)[self.playerView layer]).bounds;
}
}
}
source
share