carvalhaes
asked on
Rotating a video with iPhone Simulator
Hi.
I used this youtube video (http://www.youtube.com/watch?v=j6922mZ0WUU) to make an application where an iPhone shows a video.
However, starting at 4:25, I used another code (the code of the video does not work with the current sdk).
Here's the code that i used:
The application is running ok but when I turn the iPhone simulator the video doesn't rotate.
What changes should I do in my code?
Thanks and sorry for my bad english!
I used this youtube video (http://www.youtube.com/watch?v=j6922mZ0WUU) to make an application where an iPhone shows a video.
However, starting at 4:25, I used another code (the code of the video does not work with the current sdk).
Here's the code that i used:
- (IBAction)playMovie {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"MOVIE001" ofType:@"mov"]];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {
// Use the new 3.2 style API
moviePlayer.controlStyle = MPMovieControlStyleNone;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
} else {
// Use the old 2.0 style API
moviePlayer.movieControlMode = MPMovieControlModeHidden;
[moviePlayer play];
}
}
The application is running ok but when I turn the iPhone simulator the video doesn't rotate.
What changes should I do in my code?
Thanks and sorry for my bad english!
ASKER
could you explain better how can i "make new class derived from the movie controller and add method"?
how can i use this class instead of the MPMoviePlayerController?
how can i use this class instead of the MPMoviePlayerController?
ASKER
i try to open.
FIRST LINK:
i put:
- (BOOL)shouldAutorotateToIn terfaceOri entation:( UIInterfac eOrientati on)toInter faceOrient ation
{
return UIInterfaceOrientationIsLa ndscape(to InterfaceO rientation );
}
inside the ibaction playmovie.
the video now is widescreen, but when i rotate the iphone simulator the video dont rotate.
and at .h, when i try to put
@interface MyMovieViewController : MPMoviePlayerViewControlle r
@end
i got an error cannot find interface declaration for 'MPMoviePlayerController', superclass of 'MyMovieViewController'
FIRST LINK:
i put:
- (BOOL)shouldAutorotateToIn
{
return UIInterfaceOrientationIsLa
}
inside the ibaction playmovie.
the video now is widescreen, but when i rotate the iphone simulator the video dont rotate.
and at .h, when i try to put
@interface MyMovieViewController : MPMoviePlayerViewControlle
@end
i got an error cannot find interface declaration for 'MPMoviePlayerController',
MPMoviePlayerViewControlle r - that's the point. It's a night here already. Maybe because of that, I missed that before.
Here you will find full program: http://www.devx.com/wireless/Article/44642/1954
It has movieFinishedCallback (you asked in your first question about the subject).
It shows how to switch to the portrait mode:
[player setOrientation:UIDeviceOri entationPo rtrait animated:NO];
This app, when you will have it working, will be a base for other improvements.
Sorry, I just started from the code you proposed - MoviePlayer sample.
Here you will find full program: http://www.devx.com/wireless/Article/44642/1954
It has movieFinishedCallback (you asked in your first question about the subject).
It shows how to switch to the portrait mode:
[player setOrientation:UIDeviceOri
This app, when you will have it working, will be a base for other improvements.
Sorry, I just started from the code you proposed - MoviePlayer sample.
ASKER
all right but i follow the steps of this link http://www.devx.com/wireless/Article/44642/1954
but when i debug it, i can hear the sound but i cant see the video images.
i believe that is a sdk problem, because he made it with a older version than the mine.
but when i debug it, i can hear the sound but i cant see the video images.
i believe that is a sdk problem, because he made it with a older version than the mine.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Play iPhone Movies in Portrait Mode with MPMoviePlayerController using Public API’s
http://iphonedevelopertips.com/video/play-movies-in-portrait-mode-with-mpmovieplayercontroller-using-public-apis.html
You can download the source code - in the bottom of the article. It looks very nice.
The answer on your question is here:
http://stackoverflow.com/questions/3019200/how-to-rotate-an-mpmovieplayercontroller
http://stackoverflow.com/questions/2852872/mpmovieplayercontroller-fullscreen-quirk-in-ipad/3026039#3026039
You will see - people proposes to make new class derived from the movie controller and add method:
- (BOOL)shouldAutorotateToIn
{
return UIInterfaceOrientationIsLa
}
Then use this class instead of the MPMoviePlayerController.
BTW, please pay attention on movieFinishedCallback - that's answer on your question how to know when the show finished (if you are still looking for it).