Do you use iOS prior to 4.3? If so, you need to do it.
[videoPlayerView setContentURL: fURL]
Here is a snippet of code from which I am playing a video from a document folder. One of the things I would recommend is to avoid some auto-ad objects. Especially in NSURL when you have viewcontrollers. I know this should be safe, but I did not find it 100%
if ( [[NSFileManager defaultManager] fileExistsAtPath:fullpathVideoFile] == NO ) { NSLog(@"No video file found"); return self; } playbackURL = [[NSURL alloc] initFileURLWithPath:fullpathVideoFile isDirectory:NO]; if ( playbackURL == nil ) { NSLog(@"playbackURL == nil"); return self; } [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerLoadedMovie:) name:@"MPMoviePlayerLoadStateDidChangeNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerStartedMovie:) name:@"MPMoviePlayerNowPlayingMovieDidChangeNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerFinishedMovie:) name:@"MPMoviePlayerPlaybackDidFinishNotification" object:nil]; [self setContentURL:playbackURL];
In my case, I created a subclass of MPMoviePlayerController (as I usually do with all view controllers), so the references to the self will be associated with an instance of the MPMoviePlayerController object
source share