让MpMoviePlayerViewController播放时自动横屏
2014-03-17 22:44
561 查看
网上有很多关于MpMoviePlayerViewController播放时自动横屏的教程,但试用了好些个也不行.总结过后得出以下方法:
首先,在AppDelegate.m文件中,加入:
再写一个继承自MPMoviePlayerViewController的类:
这样 在播放的时候,自动就会跳转为横屏.并且返回后跳回竖屏.
首先,在AppDelegate.m文件中,加入:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { // UIInterfaceOrientationMaskLandscape 支持左右横屏 // UIInterfaceOrientationMaskAll 支持四个方向旋转 // UIInterfaceOrientationMaskAllButUpsideDown 支持除了UpsideDown以外的旋转 return UIInterfaceOrientationMaskAllButUpsideDown; }
再写一个继承自MPMoviePlayerViewController的类:
// // MyMoviePlayViewController.h // Medicine // // Created by Jz on 14-3-17. // Copyright (c) 2014年 Jz. All rights reserved. // // 重写MpMoviePlayerController类 实现自动横屏 #import <MediaPlayer/MediaPlayer.h> @interface MyMoviePlayViewController : MPMoviePlayerViewController @end在MyMoviePlayViewController.m中:
MyMoviePlayerViewController.m - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIDeviceOrientationIsLandscape(interfaceOrientation); } - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } - (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window { return UIInterfaceOrientationMaskAllButUpsideDown; }最后:
#import "MyMoviewPlayViewController" .......... MyMoviePlayViewController *playerVC = [[MyMoviePlayViewController alloc] initWithContentURL:XXXXXXX]; [self presentMoviePlayerViewControllerAnimated: playerVC];
这样 在播放的时候,自动就会跳转为横屏.并且返回后跳回竖屏.
相关文章推荐
- MPMoviePlayerViewController的自动横屏播放
- MPMovieplayerviewcontroller播放结束后自动消失的解决方案
- iOS开发:避免MPMoviePlayerViewController播放完毕后自动dismiss,进入后台自动dismiss
- iOS开发:避免MPMoviePlayerViewController播放完毕后自动dismiss,进入后台自动dismiss - Azure_Sagi
- 避免MPMoviePlayerViewController播放完毕后自动dismiss,进入后台自动dismiss
- 避免MPMoviePlayerViewController播放完毕后自动dismiss,进入后台自动dismiss
- MPMovieplayerviewcontroller播放结束后自动消失的解决方案
- 利用MPMoviePlayerViewController实现简单的mp4播放
- MPMoviePlayerViewController或MPMoviePlayerController播放本地视频报错:_itemFailedToPlayToEnd: {kind = 1;new =
- iPhone开发之音视频的播放——MPMoviePlayerViewController和AVAutoPlayer的使用
- iOS开发--利用MPMoviePlayerViewController播放视频简单实现
- MPMoviePlayerViewController播放在线视频
- MPMoviePlayerController刚进入ViewController就横屏满屏幕播放
- ios MPMoviePlayerViewController播放结束时的回调方法
- MPMoviePlayerViewControllerIOS6下实现横屏播放
- 使用MPMoviePlayerViewController播放视频--
- ios播放视频文件一般使用 MPMoviePlayerViewController 和 MPMoviePlayerController
- iOS用MPMoviePlayerViewController 播放MP4视频
- iOS播放视频 MPMoviePlayerViewController 和 MPMoviePlayerController 使用说明
- iOS用MPMoviePlayerViewController 播放MP4视频