Trong ứng dụng của tôi, tôi đang cố gắng phát nhiều video trong UITableViewCell
cho điều này Tôi đang sử dụng MPMoviePlayerController
nó phát video mà không gặp bất kỳ sự cố nào. nhưng nó phát một video tại một thời điểm và trong ô khác tôi nhận được màn hình màu đen giả sử ở lần đầu tiên một ô hiển thị nó phát video nhưng ngay sau khi tôi cuộn cho hàng thứ hai thì lượt xem video đầu tiên biến mất với màn hình màu đen. Tôi không hiểu cách hiển thị tất cả chế độ xem video ngay cả khi tôi cuộn chế độ xem bảng. đây là đoạn code tôi đang sử dụng cho video chơi trong phòng giam tùy chỉnh:Nhiều vấn đề phát video trong UITableViewCell
Tuỳ di động khởi tạo:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self){
NSArray *nibArray=[[NSBundle mainBundle]loadNibNamed:@"CustomCell" owner:self options:nil];
self=[nibArray objectAtIndex:0];
_player = [[MPMoviePlayerController alloc] init];
_player.view.frame = CGRectMake(0,0,320,300);
_player.movieSourceType = MPMovieSourceTypeStreaming;
[_player setContentURL:[NSURL URLWithString:@"http://files.parse.com/ef5649ee-75c6-4c76-ba3b-37be4d281125/b35589f7-c0aa-4ca8-9f7c-fd31b2dc8492-vedioTeaser.mov"]];
[_player prepareToPlay];
[_player play];
[self addSubview:_player.view];
}
return self;
}
phương pháp cellForRowAtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil){
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}else{
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section], nil] withRowAnimation:UITableViewRowAnimationAutomatic];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
Bất kỳ trợ giúp sẽ được đánh giá cao.
Hey @vinod - bạn có tìm thấy một giải pháp thanh lịch cho việc này không? Tôi đang đấu tranh với điều này quá (tôi cần điều khiển để nguyên AVFoundation là không tốt) – Boaz