简体   繁体   中英

Can't get size of the video in AVPlayerLayer on screen

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM