如何知道ALAsset网址是否包含视频或图片?

时间:2013-06-19 12:52:54

标签: iphone ios ios5 ios6 ios4

我正在处理应用程序,其中我正在获取存储在库中的视频和图像的资产URL。 我想知道动态网址包含图片或视频..

ALAsset对象可以使用属性DefaultAssetRepresentation,该属性返回资产对象的MetaData,其中包含从库中提取的图像或视频。

但我已经拥有资产网址,我不认为使用ALAsset。

所以有人知道如何检查资产网址是否包含图片或视频? 我在很多地方搜索但没有得到任何东西。请帮我解决这个问题。

提前致谢!!

1 个答案:

答案 0 :(得分:30)

http://developer.apple.com/library/ios/#documentation/AssetsLibrary/Reference/ALAsset_Class/Reference/Reference.html#//apple_ref/occ/instm/ALAsset/valueForProperty

我认为最好的方法是

if ([[asset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) {
    // asset is a video
} 

http://developer.apple.com/library/ios/#documentation/AssetsLibrary/Reference/ALAsset_Class/Reference/Reference.html#//apple_ref/doc/constant_group/Asset_Types

资产类型

指定资产类型的常量。

NSString *const ALAssetTypePhoto;
NSString *const ALAssetTypeVideo;
NSString *const ALAssetTypeUnknown;
相关问题