我尝试使用XCode& amp;来尝试使用Objective-C对视频播放器进行编码指南,但由于某种原因我收到了错误,而且我对Objective C很新,确切的错误代码是 - Property 'frame' not found on object of type AVPlayer.
Viewcontroller.h
@property (nonatomic) IBOutlet AVPlayer *avPlayer;
@property (nonatomic, strong) NSMutableString *frame;
Viewcontroller.m
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"vid" ofType:@"mp4"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
self.avPlayer = [AVPlayer playerWithURL:fileURL];
AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
layer.frame = CGRectMake(0, 0, 1024, 768); //error point
[self.view.layer addSublayer: layer];
[self.avPlayer play];
}
在尝试了多个其他人之后,我一直在关注本指南 - http://jacopretorius.net/2013/02/playing-video-in-ios.html。
我的问题是,为什么不宣布这样的框架'我还试过AVPlayer对象的多个ID&不同的方式来编码视频播放器。
我也试过了 -
答案 0 :(得分:1)
错误消息指出您正在尝试使用AVPlayer.frame
而不是AVPlayerLayer.frame
,因此我认为您错误地输入了类似的代码:
AVPlayer *layer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
^^^^^^^^