2

I have a view with layer(AVPlayerLayer) that contains video player(AVPlayer).

I used code from developer.apple.com to show video on the screen.

@implementation PlayerView
+ (Class)layerClass {
    return [AVPlayerLayer class];
}
- (AVPlayer*)player {
    return [(AVPlayerLayer *)[self layer] player];
}
- (void)setPlayer:(AVPlayer *)player {
    [(AVPlayerLayer *)[self layer] setPlayer:player];
}
@end

How i can get size of the video in playerview.frame? I can't use videoGravity for fill entire frame of the view, because i need to display landscape and portrait video.

Cœur
  • 34,719
  • 24
  • 185
  • 251
Andrey Banshchikov
  • 1,522
  • 2
  • 15
  • 26

1 Answers1

1

You can use videoRect property of the AVPlayerLayer. You can read more about it in the documentation.

Vahan Babayan
  • 684
  • 6
  • 19