AVPlayerLayer:只是播放视频,没有暂停、快进等其他按钮生成
#import <AVFoundation/AVFoundation.h>
#import <AVKit/AVKit.h>
-(void)playII{
1、//文件路径
NSString* path=[[NSBundle mainBundle]pathForResource:@"胡彦斌-还魂门.mp4" ofType:nil];
2、// 转换成url
NSURL* url=[NSURL fileURLWithPath:path];
3、//AVPlayer可以播放任何格式视频的播放器 需要引进AVFoundation框架
AVPlayer* player=[AVPlayer playerWithURL:url];
AVPlayerLayer* playerLayer=[AVPlayerLayer playerLayerWithPlayer:player];
playerLayer.frame=CGRectMake(0, 0, WIDTH, HEIGHT);//WIDTH、HEIGTH全局的宏定义
//加载到layer图层上
[self.view.layer addSublayer:playerLayer];
[player play];//播放
[player pause];//暂停
}
AVPlay