0
votes

i'm pretty new to xcode and i'm using xcode4, constructing an app with the storyboards. Now, this is my code to display a simple video taken from inside my project:

-(IBAction)playMoviePoliReel:(id)sender { NSString *filepath = [[NSBundle mainBundle] pathForResource:@"SAMPLE" ofType:@"MOV"]; NSURL *fileURL = [NSURL fileURLWithPath:filepath];

moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];

[[NSNotificationCenter defaultCenter] addObserver:self
 selector:@selector(moviePlaybackComplete:)
 name:MPMoviePlayerPlaybackDidFinishNotification
 object:moviePlayerController];

moviePlayerController.shouldAutoplay = YES;
[self.view addSubview:moviePlayerController.view];
[moviePlayerController.view setFrame:CGRectMake(31, 130, 477, 360)]; 
moviePlayerController.fullscreen = YES; 
[moviePlayerController play];
setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];
}
(void)moviePlaybackComplete:(NSNotification *)notification  
{  
MPMoviePlayerController *moviePlayerController = [notification object];  
[[NSNotificationCenter defaultCenter] removeObserver:self  
                                                name:MPMoviePlayerPlaybackDidFinishNotification  
                                              object:moviePlayerController];  
[moviePlayerController.view removeFromSuperview];  
}  

I have the video called SAMPLE.MOV in my project, in the directory resources, and created a button that onTouchDown make the function PlayVideoPoliReel go ahead... but, for a reason i cannot explain, in the player i see no video and no audio. The function seems to load the file cause in the player i see the time lasting to the end of the video and it's correct. The video only plays totally black...

I controlled if the video is seen by the program with an if NSFileManager defaultManager]fileExistsAtPath:filepath] and the file exist...

Additionally if i use

NSURL *fileURL = [NSURL URLWithString:@"http://www.ebookfrenzy.com/ios_book/movie/movie.mov"];

using a video taken from the web, the player function perfectly. The video is loaded and i can see audio and video... I'm getting mad on this! Please help me.

1

1 Answers

0
votes

If the movie is drm'd it will play all black as you described, is the sample movie drm'd? Movies and TV from the iTunes store can't be played from your application.