Video File thumbnail timestamp missing in ALAsset

為{幸葍}努か 提交于 2019-12-11 15:36:49

问题


hi i am getting all photos and videos thumbnails from ALAsset library.
my code works fine i am getting photos and video thumbnail.but in video thumbnail missing Video icon and its time stamp.

[assetImageView setImage:[UIImage imageWithCGImage:[self.asset thumbnail]]];


i am getting like above..i am using ELCImagePickerDemp API


i need to get like this i am missing time and icon in lower right corner thumbnail. any help will be appreciated... THX


回答1:


The assetslibrary thumbnail as you noticed does not include the symbol and time information in the thumbnail. So you have to draw those yourself on the thumbnail using the information you get from Alassetslibrary (check ALAssetPropertyType and ALAseetPropertyDuration to get the info you need to draw these yourself).

Cheers,

Hendrik




回答2:


Replace filter in code form "allPhotos" with "allAssets" in two places in ELCAlbumPickerController.m class

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

                  // replace [g setAssetsFilter:[ALAssetsFilter allPhotos]];  as it filter only photo
                   [g setAssetsFilter:[ALAssetsFilter allAssets]];  //gives allassets
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

 // replace [picker.assetGroup setAssetsFilter:[ALAssetsFilter allPhotos]]; as it filer only photo 
    **[picker.assetGroup setAssetsFilter:[ALAssetsFilter allAsset]];** // gives allassets
}

now all asset will be shown in Library.To differentiate between video and image thumbnail , you now have to add some code ELCAsset.m class in constructor

-(id)initWithAsset:(ALAsset*)asset_ {
if ([self.asset valueForProperty:ALAssetPropertyType] == ALAssetTypeVideo ){
         // code for video thumbnail 
       // you can use this link to understand video thumbnail 
     //http://stackoverflow.com/questions/11688938/alasset-thumbnail-at-specific-timestamp
}

    if ([self.asset valueForProperty:ALAssetPropertyType] == ALAssetTypePhoto ){
             // code for Photo thumbnail 
    }

}


来源:https://stackoverflow.com/questions/10896527/video-file-thumbnail-timestamp-missing-in-alasset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!