drexsien
drexsien

Reputation: 952

objective c MPMoviePlayerController wont work on iOS 4.3

Ive got this code from an ebook tutorial on embedding MPMoviePlayerController from a VIEW object but it just dont work at all on iOS 4.3, it just gives me a black screen. I've tried looking at other sources and they have the same source code. Can anyone help me on finding what is the problem in this code.

Thanks

    - (IBAction)playMovie:(id)sender {
    NSString *filepath = [[NSBundle mainBundle] pathForResource:@"shawarma" ofType:@"mp4"];
    NSURL *fileURL = [NSURL fileURLWithPath:filepath]; 
    MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
    [player.view setFrame: movieHolder.bounds]; 
    [movieHolder addSubview: player.view];
    [player play];
}

My VIEW object has a dimension of 400 x 300.

Upvotes: 0

Views: 653

Answers (2)

iphonedev23
iphonedev23

Reputation: 991

There is no issue with MPMoviePlayer and ios 4.3 i am working on an application that plays movie from a server and this is working fine for me. I request you to check

  1. Path of you resource try some hardcode path.
  2. Frame of the MoviePlayer.

Thanks

Upvotes: 0

Praveen-K
Praveen-K

Reputation: 3401

From the MPMoviePlayerController class reference guidelines Consider a movie player view to be an opaque structure.

You can add your own custom subviews to layer content on top of the movie but you must never modify any of its existing subviews.

In addition to layering content on top of a movie, you can provide custom background content by adding subviews to the view in the backgroundView

MPMoviePlayerController it self has a property view to present the video

Hope this LINK might help you

Upvotes: 1

Related Questions