I have a tableview that contains a list of videos (stored locally on the phone) and when a user taps a cell, I want it to play the corresponding video. Here is the code I use:
I have checked and confirmed that "filePath" is a path to a valid video file. But when I run the app and tap on a cell, a movieplayer appears shortly but then the movieplayer disappears immediately without ever playing the video.
EDIT: Okaaaaayyyy...It just started working. I literally haven't changed a line of code. I got up off the computer for about 20 minutes while waiting for an answer, came back and just ran it again, and it worked...
EDIT2: What is going on here?!? My phone is jailbroken. If I reboot the springboard using SBSettings, the video player in my app ceases to work. But then I can go into iFile, go to the directory with the videos in it, select a video and use iFile's video player to begin playing it. After the iFile video player plays it for just a second or two, I can exit out of iFile, go into my app and the video player in my app will work. But if I ever restart my springboard or restart my phone, my app no longer works and I have to do this wierd fix with iFile again. What?!?
Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
NSString *filePath = self.filePaths[indexPath.row];
NSURL *url = [NSURL fileURLWithPath:filePath];
self.movieViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[self.movieViewController.moviePlayer setFullscreen:YES];
[self presentMoviePlayerViewControllerAnimated:self.movieViewController];
[self.movieViewController.moviePlayer play];
}
I have checked and confirmed that "filePath" is a path to a valid video file. But when I run the app and tap on a cell, a movieplayer appears shortly but then the movieplayer disappears immediately without ever playing the video.
EDIT: Okaaaaayyyy...It just started working. I literally haven't changed a line of code. I got up off the computer for about 20 minutes while waiting for an answer, came back and just ran it again, and it worked...
EDIT2: What is going on here?!? My phone is jailbroken. If I reboot the springboard using SBSettings, the video player in my app ceases to work. But then I can go into iFile, go to the directory with the videos in it, select a video and use iFile's video player to begin playing it. After the iFile video player plays it for just a second or two, I can exit out of iFile, go into my app and the video player in my app will work. But if I ever restart my springboard or restart my phone, my app no longer works and I have to do this wierd fix with iFile again. What?!?
Last edited: