Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用AVComposition定制resourceLoader_Ios_Objective C_Avfoundation_Avplayer_Avcomposition - Fatal编程技术网

Ios 使用AVComposition定制resourceLoader

Ios 使用AVComposition定制resourceLoader,ios,objective-c,avfoundation,avplayer,avcomposition,Ios,Objective C,Avfoundation,Avplayer,Avcomposition,有没有办法将自定义resourceLoader与AVComposition一起使用?当我在AVURLAsset上设置resourceLoader并使用该资产创建AVPlayerItem时,我会得到AVAssetResourceLoaderDelegate回调。但是如果我在AVComposition中使用相同的AVURLAsset,就不会得到委托回调。事实上,它从未从将资产插入组合的调用中返回 使用AVURLAsset调用的AVAssetResourceLoaderDelegate方法: NSUR

有没有办法将自定义resourceLoader与AVComposition一起使用?当我在AVURLAsset上设置resourceLoader并使用该资产创建AVPlayerItem时,我会得到AVAssetResourceLoaderDelegate回调。但是如果我在AVComposition中使用相同的AVURLAsset,就不会得到委托回调。事实上,它从未从将资产插入组合的调用中返回

使用AVURLAsset调用的AVAssetResourceLoaderDelegate方法:

NSURL* mungedURL = [self mungeURL:itemURL];
AVURLAsset* asset = [[AVURLAsset alloc] initWithURL:mungedURL options:nil];
[asset.resourceLoader setDelegate:self queue:dispatch_get_main_queue()];
self.playerItem = [AVPlayerItem playerItemWithAsset:asset];
AVAssetResourceLoaderDelegate方法在AVURLAsset插入AVComposition时未调用:

NSURL* mungedURL = [self mungeURL:itemURL];
AVURLAsset* asset = [[AVURLAsset alloc] initWithURL:mungedURL options:nil];
[asset.resourceLoader setDelegate:self queue:dispatch_get_main_queue()];

AVMutableComposition* composition = [AVMutableComposition composition];
CMTimeRange timeRange = CMTimeRangeMake(kCMTimeZero, asset.duration);
[composition insertTimeRange:timeRange ofAsset:asset atTime:kCMTimeZero error:nil];

self.playerItem = [AVPlayerItem playerItemWithAsset:composition];
(实际上,它挂起在insertTimeRange:ofAsset:atTime:error。我猜它当时试图从被屏蔽的url加载—但不使用委托。)

方法调整url方案,以便调用资源加载器委托:

- (NSURL*)mungeURL:(NSURL*)url
{
    NSURLComponents* components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];
    components.scheme = @"fake-scheme";
    return [components URL];
}

你找到解决方案了吗?你找到解决方案了吗?