2013-05-07 10 views
5

में एकाधिक वीडियो प्लेइंग समस्या मेरे ऐप में मैं UITableViewCell में एकाधिक वीडियो चलाने की कोशिश कर रहा हूं, इसके लिए मैं MPMoviePlayerController का उपयोग कर रहा हूं, यह बिना किसी समस्या के वीडियो चलाता है। लेकिन यह एक समय में एक वीडियो चलाता है और दूसरे सेल में मुझे ब्लैक स्क्रीन लगता है कि पहली बार एक सेल दिखाई देता है, यह वीडियो चलाता है लेकिन जैसे ही मैं दूसरी पंक्ति के लिए स्क्रॉल करता हूं, पहला सेल वीडियो दृश्य ब्लैक स्क्रीन के साथ गायब हो जाता है। मैं तालिका दृश्य को स्क्रॉल करने के बावजूद सभी वीडियो दृश्य को कैसे दिखाना नहीं चाहता हूं।UITableViewCell

कस्टम सेल प्रारंभ:

- (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; 
} 

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; 
} 

किसी भी मदद अत्यधिक सराहना की है कि इस कोड कस्टम सेल में मैं प्ले वीडियो के लिए उपयोग कर रहा हूँ है।

+0

अरे @vinod - क्या आपको अंततः इसके लिए एक सुरुचिपूर्ण समाधान मिला? मैं इसके साथ भी संघर्ष कर रहा हूं (मुझे नियंत्रण की आवश्यकता है ताकि कच्चे AVFoundation कोई अच्छा न हो) – Boaz

उत्तर

10

आप एक साथ कई वीडियो खेलने के लिए AVFoundation framework का उपयोग कर सकते हैं। चरणबद्ध चरण और पूर्ण स्रोत कोड यह कैसे करें: multiple-video-playback-on-ios

आप MPMoviePlayerController का उपयोग नहीं कर सकते हैं। documentation कहा गया है कि स्पष्ट रूप से ..

यद्यपि आप कई MPMoviePlayerController वस्तुओं को बनाने के लिए और अपनी इंटरफ़ेस में अपने विचार पेश कर सकते हैं, एक समय में केवल एक फिल्म खिलाड़ी अपनी फिल्म खेल सकते हैं।

उम्मीद है कि यह आपकी मदद करता है।

+0

स्रोत कोड में यह फिल्म को चलाने के लिए विभिन्न नियंत्रकों का उपयोग नहीं करता है। –