Question

I am using the following code:

NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"MovieName" ofType:@"mov"];
        NSURL    *fileURL    =   [NSURL fileURLWithPath:filepath isDirectory:NO];
        MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
        [self.view addSubview:moviePlayerController.view];
        moviePlayerController.movieSourceType = MPMovieSourceTypeFile;
        moviePlayerController.contentURL = fileURL;
        moviePlayerController.fullscreen = YES;
        [moviePlayerController prepareToPlay];
        [moviePlayerController play];

However when the code is executed, the movie player appears, but the movie is never loaded.

For the sake of my own sanity, I added the following line:

NSData *thedata = [[NSData alloc]initWithContentsOfFile:filepath];

And I can verify the movie does exist, as it is loaded into the NSData object.

Where am I going working

Was it helpful?

Solution

TRY THIS :

NSString *filepath = [[NSBundle mainBundle] pathForResource:@"MovieName" ofType:@"mov"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath isDirectory:NO];

MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc]    initWithContentURL:fileURL];
moviePlayerController.view.frame = self.view.bounds;
moviePlayerController.movieSourceType = MPMovieSourceTypeFile;
moviePlayerController.fullscreen = YES;

[self.view addSubview:moviePlayerController.view];
[moviePlayerController prepareToPlay];
[moviePlayerController play];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top