2010-10-15 33 views

回答

0

我不確定你的意思是「格式」,但這段代碼將顯示視頻的UTI(基本上是文件類型)和任何元數據。

ALAssetsGroupEnumerationResultsBlock assetEnumerator = ^(ALAsset *asset, NSUInteger index, BOOL *stop) { 
    if(asset != nil) { 
     ALAssetRepresentation* representation = [asset defaultRepresentation]; 
     NSLog(@"UTI = %@", [representation UTI]); 
     NSLog(@"Metadata = %@", [representation metadata]); 
    } 
}; 

ALAssetsLibraryGroupsEnumerationResultsBlock assetGroupEnumerator = ^(ALAssetsGroup *group, BOOL *stop) { 
    if(group != nil) { 
     [group setAssetsFilter:[ALAssetsFilter allVideos]]; 
     [group enumerateAssetsUsingBlock:assetEnumerator];   
    } 
}; 

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; 
[library enumerateGroupsWithTypes:ALAssetsGroupAll 
         usingBlock:assetGroupEnumerator 
        failureBlock:^(NSError *error) { 
         NSLog(@"A problem occured. %@", error); 
        }]; 
[library release]; 

(從here修改代碼)

如果你已經有你的資產,以更新標籤的代碼如下所示:

myLabel.text = [[myAsset defaultRepresentation] UTI]; 
+0

嗨感謝您的幫助,但如何獲得使用ALAssetsRepresentation的視頻的視頻格式(例如3gp,mp4等)? – tan 2010-10-18 01:25:48

相關問題