gpt4 book ai didi

ios - PHImageManager requestAVAssetForVideo从第二次开始变为零

转载 作者:行者123 更新时间:2023-12-01 17:47:54 24 4
gpt4 key购买 nike

此代码首次正常运行。

PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc]init];
options.version = PHVideoRequestOptionsVersionCurrent;
options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
options.networkAccessAllowed = YES;
[[PHImageManager defaultManager] requestAVAssetForVideo:self.phAsset options:nil resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
dispatch_async(dispatch_get_main_queue(), ^{
AVURLAsset *urlAsset = (AVURLAsset*)asset;
NSURL *url = urlAsset.URL;
completionHandler(url);
});
}];

从第二次起,我将'asset'和'audioMix'设为nil。
“信息”如下
{
PHImageResultDeliveredImageFormatKey = 0;
PHImageResultIsInCloudKey = 0;
PHImageResultWantedImageFormatKey = 20002;
}

注意:发生这种情况后,无法从“照片”中播放相同的视频
应用。

当我使用上面的代码时,正在获取如下所示的URL(仅第一次,第二次以后,URL变为nil)

文件:///Users/OD-1007/Library/Developer/CoreSimulator/Devices/66C92D6B-B528-40A4-A238-FC8C664E3774/data/Media/DCIM/100APPLE/IMG_0011.mp4

当我使用UIImagePickerController时,它可以正常工作,并且网址为

文件:/// Users / OD-1007 / Library / Developer / CoreSimulator / Devices / 66C92D6B-B528-40A4-A238-FC8C664E3774 / data / Containers / Data / Application / 35B00947-04A4-4906-8E16-21FB4FF5A3F5 / tmp / trim .74E42978-8B87-4C37-9B4C-8B70122A794F.MOV

最佳答案

我认为您的请求存在问题,因为Apple Photo无法同步到iCloud。这使得PHVideoRequestOptionsVersionCurrent由于某些未记录的原因而无法工作。如果您将版本切换到:

PHVideoRequestOptionsVersionOriginal 

它应该工作。就我而言,这就是导致该问题的原因,并且为我解决了该问题。
PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc]init];
options.version = PHVideoRequestOptionsVersionOriginal;
options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
options.networkAccessAllowed = YES;
[[PHImageManager defaultManager] requestAVAssetForVideo:self.phAsset options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
dispatch_async(dispatch_get_main_queue(), ^{
AVURLAsset *urlAsset = (AVURLAsset*)asset;
NSURL *url = urlAsset.URL;
completionHandler(url);
});
}];

编辑:请求选项未传递。

HTH,

关于ios - PHImageManager requestAVAssetForVideo从第二次开始变为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42552633/

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