I am trying to get my application to play a video file uploaded to a document directory. I know the file is loading, but I can’t get the file to play, here is my code:
-(IBAction)play{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"%@/piggy.m4v"];
NSURL *movieURL = [NSURL fileURLWithPath:path];
_player = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[self.view addSubview:_player.view];
_player.controlStyle = MPMovieControlStyleDefault;
_player.shouldAutoplay = YES;
[_player setFullscreen:YES animated:YES];
[_player play];
}
source
share