Parvez Belim
Parvez Belim

Reputation: 1013

How to know whether ALAsset url contains video or image?

I am working on application in which I am getting an asset urls of the videos and images which are stored in library. I want to know dynamically the url contains image or video ..

It is possible with ALAsset object having the property DefaultAssetRepresentation which returns the MetaData of asset object,which contains image or video fetched from the library.

but i already had asset urls and I am not suppose to use ALAsset.

So anybody know how to check whether asset url contains image or video ? I searched at many places but didn't get anything.Please help me sort out this issue.

Thanks in advance !!

Upvotes: 3

Views: 4534

Answers (1)

adali
adali

Reputation: 5977

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

i think best way is

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

Asset Types

Constants that specify the type of an asset.

NSString *const ALAssetTypePhoto;
NSString *const ALAssetTypeVideo;
NSString *const ALAssetTypeUnknown;

Upvotes: 30

Related Questions