gpt4 book ai didi

objective-c - requestAVAssetForVideo 不显示完成 block

转载 作者:行者123 更新时间:2023-12-05 08:11:58 38 4
gpt4 key购买 nike

我有这段代码来加载 PHAsset:

PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
options.networkAccessAllowed = YES;

[[PHImageManager defaultManager] requestAVAssetForVideo:[videos objectAtIndex:index] options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
selectedAsset = asset;
}];

它可以完美处理设备上存储的视频。但是如果代码应该从 iCloud 加载视频,它不会调用完成 block 。你能帮帮我吗?

最佳答案

请尝试附加代码 1 到 3

PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
options.networkAccessAllowed = YES;

//Additional code 1
dispatch_semaphore_t semaphore = dispatch_semaphore_create(1);

[[PHImageManager defaultManager] requestAVAssetForVideo:[videos objectAtIndex:index] options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
selectedAsset = asset;

//Additional code 2
dispatch_semaphore_signal(semaphore);

}];

//Additional code 3
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);

关于objective-c - requestAVAssetForVideo 不显示完成 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41705090/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com