【问题标题】:How to know whether ALAsset url contains video or image?如何知道 ALAsset url 是否包含视频或图像?
【发布时间】:2013-06-19 12:52:53
【问题描述】:

我正在开发应用程序,在该应用程序中我获取存储在库中的视频和图像的资产 URL。 我想动态知道 url 包含图像或视频..

可以使用具有 DefaultAssetRepresentation 属性的 ALAsset 对象,该属性返回资产对象的元数据,其中包含从库中获取的图像或视频。

但我已经有了资产 url,我不打算使用 ALAsset。

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

提前致谢!!

【问题讨论】:

标签: iphone ios ios5 ios6 ios4


【解决方案1】:

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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-29
    • 1970-01-01
    • 1970-01-01
    • 2010-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多