I am playing an video from document directory in the collection view using below code
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath;
{
if (indexPath.item==0) {
NSURL *vedioURL;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSArray *filePathsArray = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:documentsDirectory error:nil];
NSLog(@"files array %@", filePathsArray);
//reverse the array
// NSArray* reversedArray = [[filePathsArray reverseObjectEnumerator] allObjects];
// NSLog(@"%@",reversedArray);
NSString *fullpath;
for ( NSString *apath in filePathsArray )
{
fullpath = [documentsDirectory stringByAppendingPathComponent:apath];
vedioURL =[NSURL fileURLWithPath:fullpath];
}
NSLog(@"vurl %@",vedioURL);
MPMoviePlayerViewController *videoPlayerView = [[MPMoviePlayerViewController alloc] initWithContentURL:vedioURL];
videoPlayerView.view.frame = CGRectMake(0, 60, 412,229);
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
[view addSubview:videoPlayerView.view];
[self.view addSubview:view];
[self presentMoviePlayerViewControllerAnimated:videoPlayerView];
[videoPlayerView.moviePlayer play];
}
When I click on the image video is playing,but I want that video to be played in same position in the same cell.