Objective-c、属性 'frame' 未在 AVPlayer 类型的对象上找到
Objective-c, property 'frame' not found on object of type AVPlayer
我正在尝试使用 XCode 和指南在 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 在尝试了多个其他指南之后。
我的问题是,为什么声明 'frame' 不起作用,我还尝试了 AVPlayer 对象的多个 ID 以及对视频播放器进行编码的不同方法。
我也试过了 -
Whosebug error
Whosebug error 2
错误消息指出您正在尝试使用 AVPlayer.frame
而不是 AVPlayerLayer.frame
,因此我认为您输入的代码有误,如下所示:
AVPlayer *layer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
^^^^^^^^
我正在尝试使用 XCode 和指南在 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 在尝试了多个其他指南之后。
我的问题是,为什么声明 'frame' 不起作用,我还尝试了 AVPlayer 对象的多个 ID 以及对视频播放器进行编码的不同方法。
我也试过了 -
Whosebug error Whosebug error 2
错误消息指出您正在尝试使用 AVPlayer.frame
而不是 AVPlayerLayer.frame
,因此我认为您输入的代码有误,如下所示:
AVPlayer *layer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
^^^^^^^^