我对 Obj-C 和块的概念还很陌生。我读了这篇关于显示从 ALAssets 检索的 url 中的图像的文章:在 iPhone 中显示从 ALAsset 检索到的 URL 中的图像 https://stackoverflow.com/questions/3837115/display-image-from-url-retrieved-from-alasset-in-iphone
除了能够查看图片文件UITableView
使用ALAsset
框架,我希望能够播放存储在图片文件夹中的视频。视频资源的显示方式就像图片一样,因此我希望能够点击表格中的视频列表并播放它。 (换句话说,我想使用资产库框架播放视频)
这可以用以下方法完成吗MPMoviePlayerController
?
从上面的帖子中,我收集到我需要此函数内的代码来获取视频文件的资源 URL:
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
};
如果这是正确的,我需要在该函数中放入什么代码,以便我可以通过以下方式成功播放视频MPMoviePlayerController
?
仅供参考,我的用于显示资产的代码UITableView
在这儿:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = @"id";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
[[cell imageView] setImage:[UIImage imageWithCGImage:[[assets objectAtIndex:indexPath.row] thumbnail]]];
[[cell textLabel] setText:[NSString stringWithFormat:@"Item %d", indexPath.row+1]];
return cell;
}
这是我的第一篇文章,所以如果我发错了,我很抱歉。感谢您的帮助