Andrey Banshchikov Andrey Banshchikov - 1 year ago 191
Objective-C Question

How to get video frame of the AVPlayer?

I have PlayerView class for displaying AVPlayer's playback. Code from documentation.

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>

@interface PlayerView : UIView
@property (nonatomic) AVPlayer *player;

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

I set up my AVPlayer (contains video asset with size 320x240) in this PlayerView (with frame.size.width = 100, frame.size.height = 100) and my video is resized. How can i get size of video after adding in PlayerView?

Answer Source

In iOS 7.0 added new feature:

AVPlayerLayer has property videoRect