AVPlay播放视频
@property (nonatomic,retain, nullable)AVPlayer *player;NSString *urlStr= [[NSBundlemainBundle]pathForResource:@"demo.mp4"ofType:nil];NSURL *url=[NSURLfileURLWithPath:urlS
·
@property (nonatomic, retain, nullable) AVPlayer *player;
NSString *urlStr= [[NSBundle mainBundle]pathForResource:@"demo.mp4" ofType:nil];
NSURL *url=[NSURL fileURLWithPath:urlStr];
AVPlayerItem *playerItem=[AVPlayerItem playerItemWithURL:url];
_player=[AVPlayer playerWithPlayerItem:playerItem];
//没这句话会死很久的,,,,
AVPlayerLayer *playerLayer=[AVPlayerLayer playerLayerWithPlayer:self.player];
playerLayer.frame = self.view.bounds;
[self.view.layer addSublayer:playerLayer];
[self.player play];
更多推荐
所有评论(0)