Я хочу создать табличное представление, чтобы вывести всю информацию о vedio. Что мне нужно, чтобы получить эскизы изображений из Интернета.
Я запрашиваю миниатюру для каждого видео при загрузке просмотра. но когда запрос завершен, центр уведомлений уведомит все видео объекты. поэтому все ячейки таблицы будут обновлять изображение одновременно. в конце все ячейки таблицы показывают одно и то же уменьшенное изображение, которое закончилось наконец.
Странно то, что он отлично работает на IOS5. Это происходит только когда я запускаю приложение на IOS4.
Вот мой код:
-(void)viewDidLoad{
dataArray = [[NSMutableArray arrayWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"vedio" ofType:@"plist"]] retain];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(receiveNotification:) name:MPMoviePlayerThumbnailImageRequestDidFinishNotification object:nil];
ctlArray = [[NSMutableArray alloc] init];
for(int i=0; i<[dataArray count]; i++){
MPMoviePlayerController * vedio = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:[[dataArray objectAtIndex:i]objectForKey:@"url"]]];
//[vedio prepareToPlay];
vedio.shouldAutoplay = NO;
vedio.controlStyle = MPMovieControlStyleEmbedded;
NSMutableDictionary * data = [NSDictionary dictionaryWithObjectsAndKeys:vedio,@"controller",[NSNumber numberWithInt:i],@"index", nil];
[ctlArray addObject:data];
NSMutableArray * allThumbnails = [NSMutableArray arrayWithObjects:[NSNumber numberWithDouble:2.0],nil];
[vedio requestThumbnailImagesAtTimes:allThumbnails timeOption:MPMovieTimeOptionExact];
}
......
}
-(void)receiveNotification:(NSNotification *)notify{
id pid = [notify object];
for(int i=0; i<[ctlArray count]; i++){
NSMutableDictionary * o= [NSMutableDictionary dictionaryWithDictionary:[ctlArray objectAtIndex:i]];
if (pid == [o objectForKey:@"controller"]) {
NSDictionary * d = [notify userInfo];
if([d objectForKey:@"MPMoviePlayerThumbnailImageKey"] != nil){
UIImage * recvdata = [d objectForKey:@"MPMoviePlayerThumbnailImageKey"];
[o setObject:recvdata forKey:@"image"];
[ctlArray replaceObjectAtIndex:i withObject:o ];
NSIndexPath *durPath = [NSIndexPath indexPathForRow:i inSection:0];
UITableViewCell * cell = [tblV cellForRowAtIndexPath:durPath];
if(cell != nil){
UIImageView* iv = (UIImageView*)[cell viewWithTag:10000];
[iv setImage:recvdata];
}
}
break;
}
}
}
Любой sugesstion будет признателен. Спасибо!