webview内的MPMoviePlayerController视频播放

应项目要求,播放器要实现全屏之后横屏,查找半天资料终于找到相应的资料
资料源://www.greatytc.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;
}

现在就可以实现全屏啦

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容