Ios AVPlayer项目获取nan持续时间(无效)
我正在使用Ios AVPlayer项目获取nan持续时间(无效),ios,objective-c,avasset,Ios,Objective C,Avasset,我正在使用AVAsset类和传递的url。但它没有提供持续时间。我只得到nan CMTime audioDuration = audioAsset.duration; float audioDurationSeconds = CMTimeGetSeconds(audioDuration); double duration = CMTimeGetSeconds(asset.duration); 试试下面的代码 AVURLAsset *asset1 = [[AVURLAsset alloc] i
AVAsset
类和传递的url。但它没有提供持续时间。我只得到nan
CMTime audioDuration = audioAsset.duration;
float audioDurationSeconds = CMTimeGetSeconds(audioDuration);
double duration = CMTimeGetSeconds(asset.duration);
试试下面的代码
AVURLAsset *asset1 = [[AVURLAsset alloc] initWithURL:info[UIImagePickerControllerMediaURL] options:nil]; // info[UIImagePickerControllerMediaURL] is url(file url) here. You should pass your url here
CMTime videoDuration = asset1.duration;
float videoDurationInSeconds = CMTimeGetSeconds(videoDuration);
并确保您的url是文件url