AVPlay播放视频

时间:2025-01-29 11:21:05

@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:];

 = ;

[ addSublayer:playerLayer];


[ play];