我有用于显示 AVPlayer 播放的 PlayerView 类。来自文档的代码。
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@interface PlayerView : UIView
@property (nonatomic) AVPlayer *player;
@end
@implementation PlayerView
+ (Class)layerClass {
return [AVPlayerLayer class];
}
- (AVPlayer*)player {
return [(AVPlayerLayer *)[self layer] player];
}
- (void)setPlayer:(AVPlayer *)player {
[(AVPlayerLayer *)[self layer] setPlayer:player];
}
@end
我在此 PlayerView(frame.size.width = 100,frame.size.height = 100)中设置了我的 AVPlayer(包含大小为 320x240 的视频资产),并且调整了我的视频大小。添加 PlayerView 后如何获取视频大小?