我有PlayerView类,用于显示AVPlayer的播放。来自documentation的代码。
#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中设置了AVPlayer(包含大小为320x240的视频资源)(frame.size.width = 100,frame.size.height = 100),并调整了视频大小。在PlayerView中添加后,如何获得视频的大小?
最佳答案
在中,iOS 7.0 添加了新功能:
AVPlayerLayer 具有属性videoRect。