gpt4 book ai didi

iphone - 我如何从 ios sdk 中的库中获取所有视频文件的列表

转载 作者:可可西里 更新时间:2023-11-01 04:10:02 26 4
gpt4 key购买 nike

您好,我正在处理视频,我想从库中获取视频文件列表以在我的应用中显示和播放视频。谁能帮帮我。

最佳答案

allVideos = [[NSMutableArray alloc] init];
ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];

[assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop)
{
if (group)
{
[group setAssetsFilter:[ALAssetsFilter allVideos]];
[group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop)
{
if (asset)
{
dic = [[NSMutableDictionary alloc] init];
ALAssetRepresentation *defaultRepresentation = [asset defaultRepresentation];
NSString *uti = [defaultRepresentation UTI];
NSURL *videoURL = [[asset valueForProperty:ALAssetPropertyURLs] valueForKey:uti];
NSString *title = [NSString stringWithFormat:@"video %d", arc4random()%100];
UIImage *image = [self imageFromVideoURL:videoURL];
[dic setValue:image forKey:@"image"];
[dic setValue:title forKey:@"name"];
[dic setValue:videoURL forKey:@"url"];
[allVideos addObject:dic];
}
}];
else
{
}
}
failureBlock:^(NSError *error)
{
NSLog(@"error enumerating AssetLibrary groups %@\n", error);
}];

关于iphone - 我如何从 ios sdk 中的库中获取所有视频文件的列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17585908/

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