我想在tableViewCell
中播放视频url's
来自服务器的视频。
这是我的代码:
cell.ImageViewPost.hidden = YES;
controllerBig = [[AVPlayerViewController alloc]init];
//setting the frame of avviewplayer
[controllerBig.view setFrame:CGRectMake(0,0,cell.bounds.size.width,cell.ViewPlayerBig.bounds.size.height)];
avPlayerLayerBig = [AVPlayerLayer layer];
[avPlayerLayerBig setPlayer:player];
avPlayerLayerBig.frame = cell.ViewPlayerBig.layer.bounds;
NSLog(@"%@Layer Frame is::::",avPlayerLayer);
// set the video player on view
controllerBig.delegate=self;
controllerBig.videoGravity = AVLayerVideoGravityResizeAspect;
// create an AVPlayer
asset = [AVURLAsset URLAssetWithURL:[NSURL URLWithString:[baseImageURl stringByAppendingPathComponent:[[ArrTotalResult valueForKey:@"post"]objectAtIndex:indexPath.row]]] options:nil];
anItem = [AVPlayerItem playerItemWithAsset:asset];
playerBig = [AVPlayer playerWithPlayerItem:anItem];
playerBig.externalPlaybackVideoGravity=AVLayerVideoGravityResizeAspectFill;
[playerBig seekToTime:kCMTimeZero];
// create a player view controller
controllerBig.player = playerBig;
[playerBig play];
[cell.layer addSublayer:avPlayerLayerBig];
[cell.ViewPlayerBig addSubview:controllerBig.view];
}
在这些表视图数组中,我有两个值,一个是图像,第二个是video.im,使用url扩展对数组值进行排序,如果数组值包含视频表视图单元格将在parrticular index上添加视频,如果它包含图像单元格将加载图像,然后avplayer将隐藏。
现在问题是表格视图在重新编码时卡住了。并没有正确显示视频。而且视频也没有放在完整的细胞框架上。