2013-05-07 29 views
5

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.

+0

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

Trả lời

10

Bạn có thể sử dụng AVFoundation framework để phát nhiều video cùng một lúc. Từng bước và mã nguồn đầy đủ về cách thực hiện việc này: multiple-video-playback-on-ios

Bạn không thể sử dụng MPMoviePlayerController. Các documentation nói rõ ràng ..

Mặc dù bạn có thể tạo nhiều đối tượng MPMoviePlayerController và hiển thị lượt xem trong giao diện của bạn, chỉ một trình phát phim có thể phát phim của nó.

hy vọng nó sẽ giúp bạn.

+0

trong mã nguồn nó sử dụng bộ điều khiển khác nhau để chơi phim không phải là một. –

Các vấn đề liên quan