I want to play video in the collection view cell,the requirement is like the instagram timeline and playing video is like playing videos in the facebook time line,
for
Finally I found answer for this,just change below code
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
//[self.collection reloadData];
homeceeCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
UIImage *image;
NSInteger row = [indexPath row];
NSURL *furl;
NSLog(@"indexpath = %ld", (long)row);
if ([app.array1[row] isKindOfClass:[NSURL class]])
{
furl=app.array1[row];
cell.movieplayer = [[MPMoviePlayerController alloc]initWithContentURL:app.array1[row]];
cell.videoview.hidden=NO;
cell.img.hidden=YES;
cell.movieplayer.view.frame = cell.img.frame;
[cell.videoview addSubview:cell.movieplayer.view];
NSLog(@"%@",cell.movieplayer);
[cell.movieplayer play];
NSLog(@"%@",cell.movieplayer);
}
else {
if ([app.array1[row] isKindOfClass:[UIImage class]]) {
image= app.array1[row];
cell.img.hidden=NO;
cell.videoview.hidden=YES;
}
else {
image = [UIImage imageNamed:app.array1[row]];
cell.videoview.hidden=YES;
cell.img.hidden=NO;
}
cell.img.image = image;
}
cell.text.text=[app.tarray1 objectAtIndex:indexPath.row];
return cell;
}