AutoRotate ONLY MpMoviePlayerControler iOS 6 [英] AutoRotate ONLY MpMoviePlayerControler iOS 6

查看:91
本文介绍了AutoRotate ONLY MpMoviePlayerControler iOS 6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的家伙
与其他人一样的问题。
如果我编辑.plist以支持所有方向,我得到了它的工作,但我只需要支持我的MPMoviePlayerController旋转(也许在我的MWPhotoBrwoser图像)

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)

我的代码:
Viewcontroller.h

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

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; }
}

这是我的最新尝试,但我已经尝试了几乎所有的东西
只需要旋转MPMovieViewController。

Is just my latest try but i have tried almost everything Only need to rotate the MPMovieViewController.

我甚至试过这个,无法让它工作
http://fostah.com/ios/2012/09/27/ios6-orientation-handling.html

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! :)

推荐答案

在阅读你的问题时:如果我编辑了.plist以支持所有方向,我就可以使用它,但是我只需要支持我的MPMoviePlayerController(也可能是我的MWPhotoBrwoser图像)的旋转,第一个注意事项是你应该允许.plist中的所有方向。 plist中允许的方向应该是应用程序中不同视图控制器必须支持的所有方向的并集。

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.

无论你在特定的视图控制器中做什么,你都不会能够允许旋转到plist中不允许的方向。

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:


  1. 允许plist中支持
    至少一个视图控制器的所有方向

  2. 对于所有单独的视图控制器,
    使用 shouldAutorotateToInterfaceOrientation (iOS5)和
    shouldAutorotate / supportedInterfaceOrientations (iOS6)

  1. Allow all orientations in the plist that are supported by at least one view controller
  2. For all individual view controllers, use the shouldAutorotateToInterfaceOrientation (iOS5) and shouldAutorotate / supportedInterfaceOrientations (iOS6)

这篇关于AutoRotate ONLY MpMoviePlayerControler iOS 6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆