我正在尝试创建一个显示视频文件的 AVPlayer。
这是我到目前为止的代码:
- (IBAction) player {
NSURL* m = [[NSBundle mainBundle] URLForResource:@"Cache" withExtension:@"mov"];
AVURLAsset* asset = [AVURLAsset URLAssetWithURL:m options:nil];
AVPlayerItem* item = [AVPlayerItem playerItemWithAsset:asset];
AVPlayer* p = [AVPlayer playerWithPlayerItem:item];
self.player = p;
AVPlayerLayer* lay = [AVPlayerLayer playerLayerWithPlayer:p];
lay.frame = CGRectMake(10, 76, 303, 265);
[self.view.layer addSublayer:lay];
[p play];
}
我已经链接到AVFoundation.framework
并且CoreMedia.framework
我已经导入了<AVFoundation/AVFoundation.h>
.
首先,我收到一个错误,上面写着property 'player' not found on object of type 'ViewController*
(对于 line self.player = p;
)。我需要做什么才能让它运行?
此外,在修复错误后,此代码是否可以正常显示视频?
提前致谢