Cocoa touch SDK 3.2 - How to play video

Possible duplicate:
Using MPMoviePlayerViewController in SDK 3.2 for iPad

How to play videos on SDK 3.2 (iPad)?

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

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

So basically I can play video on 3.1.3 with this code, but the same code won't work 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

+2


a source to share


2 answers


MPMoviePlayerController no longer works on iPad - only audio plays. You have to use MPMoviePlayerViewController to get correct functionality

Using MPMoviePlayerViewController in SDK 3.2 for iPad



Thanks for the Apple update :(

+1


a source


I got it working. Here's how:

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

      



Thanks
Tee

0


a source







All Articles