我對Obj-C和塊的想法還是比較新的。我看到這篇文章有關顯示從URL從ALAssets檢索到的圖像:display image from URL retrieved from ALAsset in iPhone從iOS中的ALAsset中檢索的URL播放視頻
除了能夠使用ALAsset
框架來查看一個UITableView
圖片文件,我希望能夠播放存儲在圖片文件夾中的視頻好。視頻資源就像一張圖片一樣顯示,所以我希望能夠在表格中點擊該視頻列表並讓它播放。 (換句話說,我想用Assets Library Framework播放視頻)
這可以用MPMoviePlayerController
來完成嗎?
從那個帖子上面我收集我需要這個代碼函數內部獲得的資產網址的視頻文件:
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;
}
這是我的第一篇文章,所以我很抱歉,如果我將它張貼錯了。感謝您的幫助
這對我不起作用。該URL包含類似'assets-library://asset/asset.MOV?id = 12345&ext = mov'。 MoviePlayerController不顯示任何內容。 – 2013-01-16 12:44:17