So I have a UITableView
, and it reads the NSDocumentDirectory
and displays (in an array) the contents of it in this table.
When you touch a cell, let's say "21 Jump Street.mp4" (this is a movie trailer app), it should play the trailer for you entitled "21 Jump Street.mp4" in the documents folder.
But when I play the movie, all I get is a black screen. If you tap on the screen you can see that the status bar appears, then disappears, over and over as you tap it. Here's my code in "didSelectRowAtIndexPath
":
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSArray *fileList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:nil];
NSString *movieLocal = [fileList objectAtIndex:indexPath.row];
NSURL *fileURL = [NSURL fileURLWithPath:movieLocal isDirectory:NO];
NSLog(@"%@", fileURL);
moviePlayer3 = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
moviePlayer3.controlStyle = MPMovieControlStyleDefault;
moviePlayer3.shouldAutoplay = YES;
[self.view addSubview:moviePlayer3.view];
[moviePlayer3 setFullscreen:YES animated:YES];
When I NSLog fileURL, this is what it shows:
21%20Jump%20Street.mp4 -- file://localhost/
Any help would be so awesome. Thanks a ton!
Did you check with a different file to see if maybe the file is corrupt or in an unsupported format encoded?