[英]video play in UIView in ios
我正在用Objective-C開發一個應用程序。
在我的UIViewController中
.h文件
@property(weak,nonatomic)IBOutlet UIView *vvv;
.m文件
// to play the video
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"alphabet learning splash" ofType:@"mp4"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
self.avPlayer = [AVPlayer playerWithURL:fileURL];
self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
AVPlayerLayer *videoLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
[_vvv.layer addSublayer:videoLayer];
[self.view addSubview:_vvv];
[ self.avPlayer play];
但是視頻沒有顯示在vvv的UIView中,如何設置?
嘗試設置界限
// to play the video
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"alphabet learning splash" ofType:@"mp4"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
self.avPlayer = [AVPlayer playerWithURL:fileURL];
self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
AVPlayerLayer *videoLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
[_vvv.layer addSublayer:videoLayer];
[self.view addSubview:_vvv];
_vvv.frame = self.bounds;
[ self.avPlayer play];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.