AVURLAsset *asset = [AVURLAsset URLAssetWithURL:[NSURL URLWithString:@"kkkk"] options:nil];
[asset.resourceLoader setDelegate:self queue:dispatch_get_main_queue()];
AVPlayerItem *item = [AVPlayerItem playerItemWithAsset:asset];
_player = [AVPlayer playerWithPlayerItem:_playerItem];
实现代理方法
#pragma mark - AVAssetResourceLoaderDelegate
- (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader
{
.....
return YES;
}
- (void)resourceLoader:(AVAssetResourceLoader *)resourceLoader didCancelLoadingRequest:(AVAssetResourceLoadingRequest *)loadingRequest {
....
}
注意
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:[NSURL URLWithString:@“kkkk”] options:nil]; 这里使用的url 需要是不合规的URL,就是无法正常请求到视频或者音频的URL,只有这样,AVPlayer 才会通过代理方法来获取
视频资源
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)