2

Possible Duplicate:
Using MPMoviePlayerViewController in SDK 3.2 for iPad

How do I play video on SDK 3.2 (iPad)?

Read many questions here but they talked mostly for iPhone.
For example, the MoviePlayer example here http://developer.apple.com/iphone/library/samplecode/MoviePlayer_iPhone/Introduction/Intro.html

That works on 3.1.3 but when I run it on 3.2, it doesn't work.

So basically I'm able to play a video on 3.1.3 using this code but the same code won't run on 3.2

NSString *moviePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Movie.mp4"];

MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]];

moviePlayer.movieControlMode = MPMovieControlModeDefault;

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];

[moviePlayer play];

Thanks,
Tee

Community
  • 1
  • 1
teepusink
  • 27,444
  • 37
  • 107
  • 147

2 Answers2

1

MPMoviePlayerController doesn't work on the iPad anymore - only audio is played. You have to use MPMoviePlayerViewController to get the correct functionality

Using MPMoviePlayerViewController in SDK 3.2 for iPad

Thanks for the update Apple :(

Community
  • 1
  • 1
Bron Davies
  • 5,930
  • 3
  • 30
  • 41
0

I got it to work. Here is how:

NSURL* videoURL = [NSURL URLWithString:url];
MPMoviePlayerController moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[moviePlayer prepareToPlay];
[moviePlayer play];
[self.view addSubview:moviePlayer.view];

Thanks,
Tee

Roozbeh Zabihollahi
  • 7,207
  • 45
  • 39
teepusink
  • 27,444
  • 37
  • 107
  • 147