okay guys
Same question as everyone else.
I got it to work if i edited the .plist to support all orientation, but i only need to support rotation at my MPMoviePlayerController (and maybe at my MWPhotoBrwoser images)
My code:
Viewcontroller.h
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
@interface MusikViewController : UIViewController{
AVAudioPlayer *audioPlayer;
}
//tilføjer vores film afspiller
@property (nonatomic, strong) MPMoviePlayerController *moviePlayer;
//Laver de to knapper
//Musik knap
- (IBAction)Play:(UIButton *)sender;
//Film knap
- (IBAction)playButton:(id)sender;
//info knap
- (IBAction)info:(id)sender;
@end
Viewcontroller.m
#import "MusikViewController.h"
@implementation MusikViewController
@synthesize moviePlayer;
- (IBAction)Play:(UIButton *)sender
{
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/roteWeste.mp4", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops = -1;
if (audioPlayer == nil){
NSLog(@"Der skete en fejl, prøv at genstarte app'en, hvis problemet bliver ved, prøv da at send en mail til Mrostgaard@gmail.com");
}
else
[audioPlayer play];
}
- (IBAction)playButton:(id)sender {
NSString *videoFile = [[NSBundle mainBundle] pathForResource:@"RoteVeste2" ofType:@"m4v"];
moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:[NSURL fileURLWithPath:videoFile]];
[self.view addSubview:moviePlayer.view];
moviePlayer.fullscreen = YES;
moviePlayer.allowsAirPlay = YES;
moviePlayer.controlStyle = MPMovieControlModeVolumeOnly;
[moviePlayer play];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
if ((UIDeviceOrientationIsLandscape(interfaceOrientation))||(UIDeviceOrientationIsLandscape(interfaceOrientation))) {
return YES;
}
else return NO;
}
else
{
if ((UIDeviceOrientationIsLandscape(interfaceOrientation))||(UIDeviceOrientationIsLandscape(interfaceOrientation))) {
return YES;
}
else return NO; }
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[audioPlayer stop]; // Or pause
}
- (IBAction)info:(id)sender {
}
@end
i just can’t seem to make it work. The code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
if ((UIDeviceOrientationIsLandscape(interfaceOrientation))||(UIDeviceOrientationIsLandscape(interfaceOrientation))) {
return YES;
}
else return NO;
}
else
{
if ((UIDeviceOrientationIsLandscape(interfaceOrientation))||(UIDeviceOrientationIsLandscape(interfaceOrientation))) {
return YES;
}
else return NO; }
}
Is just my latest try but i have tried almost everything
Only need to rotate the MPMovieViewController.
I have even tried this, could not get it to work
http://fostah.com/ios/2012/09/27/ios6-orientation-handling.html
Really hoping for some help! 🙂
When reading your question: ” I got it to work if i edited the .plist to support all orientation, but i only need to support rotation at my MPMoviePlayerController (and maybe at my MWPhotoBrwoser images)”, the first remark would be that you should allow all orientations in the .plist. The allowed orientations in your plist should be the union of all orientations the different view controllers in your application must support.
Whatever you do in a specific view controller, you will never be able to allow rotation to an orientation that is not allowed in your plist.
It is then up to all individual view controllers to say what orientations that particular view controller allows. So in steps:
least one view controller
use the
shouldAutorotateToInterfaceOrientation(iOS5) andshouldAutorotate/supportedInterfaceOrientations(iOS6)