webview内的MPMoviePlayerController视频播放

应项目要求,播放器要实现全屏之后横屏,查找半天资料终于找到相应的资料
资料源:http://www.jianshu.com/p/deecfa886dac
实现方法:
在appdelegate页面:
.h
@property(nonatomic)BOOL allowRotation;
.m

pragma mark ------------ MediaPlayer选择全屏模式

实现以下方法

  • (void)addMoviePlaybackRotateNotification{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerWillEnterFullscreenNotification:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerWillExitFullscreenNotification:) name:MPMoviePlayerWillExitFullscreenNotification object:nil];
    }
  • (void) moviePlayerWillEnterFullscreenNotification:(NSNotification*)notification {
    self.allowRotation = YES;
    }
  • (void) moviePlayerWillExitFullscreenNotification:(NSNotification*)notification {
    self.allowRotation = NO;
    }

-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (self.allowRotation) {
项目要求直接横屏,所以我只选择一个方向。
return UIInterfaceOrientationMaskLandscapeRight;
}
return UIInterfaceOrientationMaskPortrait;
}

现在就可以实现全屏啦

你可能感兴趣的:(webview内的MPMoviePlayerController视频播放)