我陷入了一个大问题。 我有一个tableview有videoplayer - AVPlayer 我有10个单元格,每个播放视频。但问题是,当我滚动tableview播放器获得重新初始化和视频播放从 开始。我想要阻止这个重新初始化和播放视频像我们离开作为最后的代码应该试图玩的视频 ?我曾尝试多个代码,但没有获得成功如何防止avplayer的单元格 - Tableview从重新初始化
Code is here
if (Arr_avPlayer.count > indexPath.row){
Cell_TVC * cell = (Cell_TVC *)[Arr_avPlayer
objectAtIndex:indexPath.row];
return cell;
}
// Cell_TVC *cell = (Cell_TVC *)[tableView
dequeueReusableCellWithIdentifier:@"Cell_TVC"
forIndexPath:indexPath];
**Cell_TVC *cell = [[Cell_TVC alloc] init];**
// Cell_TVC *cell = [tableView
dequeueReusableCellWithIdentifier:@"Cell_TVC"];
// if (!cell) {
// cell = [[Cell_TVC
alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"Cell_TVC"];
//
// }
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:[NSURL
fileURLWithPath:[self filepath:[myIntegers
objectAtIndex:indexPath.row]]] options:nil];
cell.avPlayerItem = [[AVPlayerItem alloc] initWithAsset:asset];
cell.avPlayer = [[AVPlayer alloc]
initWithPlayerItem:cell.avPlayerItem];
cell.avPlayerLayer = [[AVPlayerLayer alloc] init];
cell.avPlayerLayer = [AVPlayerLayer
playerLayerWithPlayer:cell.avPlayer];
cell.lblTime.text = @"0.0";
CGRect contentViewFrame = cell.contentView.frame;
contentViewFrame.origin.x = 0;
contentViewFrame.origin.y = 25;
contentViewFrame.size.width = APP_width;
contentViewFrame.size.height = APP_width * 0.55;
cell.contentView.frame = contentViewFrame;
cell.contentView.backgroundColor = [UIColor redColor];
UILabel *lbl = [[UILabel
alloc]initWithFrame:CGRectMake((cell.contentView.frame.size.width/2
) - 100, contentViewFrame.size.height + 10, 200, 100)];
//lbl.text = [NSString stringWithFormat:@"%02f:%02f", dMinutes11,
dSeconds11];
lbl.tag = indexPath.row;
[cell.avPlayerLayer setFrame:cell.contentView.frame];
[cell.contentView.layer addSublayer:cell.avPlayerLayer];
[Arr_avPlayer insertObject:cell atIndex:indexPath.row];
[cell.contentView addSubview:lbl];
if i write the cell like below
Cell_TVC *cell = [[Cell_TVC alloc] init];
i am not able to acess the property of cell and when i use like
below
if (!cell)
{
cell = [[Cell_TVC
alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"Cell_TVC"];
}
玩家指数变化和视频得到改变其指数 如何得到这个问题的拼车?
你需要维护AVPlayer在tableview的数据源上的查找时间 –
从那里的代码? '的tableView:的cellForRowAtIndexPath:'?你需要你的代码很混乱,请格式化你的问题。另外,请使用出列,并使用单元格的重用。避免在那里添加子视图,因为重用。 – Larme
Anbu.Karthik现在我不想seektime我只想要一种方法来防止重新avialyer – Anita