IOS视屏播放过程中横竖屏切换
来源:互联网 发布:上古卷轴ol捏脸数据 编辑:程序博客网 时间:2024/05/29 04:36
最近在做视屏播放,我用的系统原生的播放器,但是横竖屏切换的时候遇到问题,这里是我的解决办法,记在此处,日后查找也方便。
首先在AppDelegate中如下写:
//appdelegate.h加 @property (nonatomic, assign) BOOL allowRotation;//appdelegate.m加 -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ if (self.allowRotation) { return UIInterfaceOrientationMaskPortrait |UIInterfaceOrientationMaskLandscapeLeft |UIInterfaceOrientationMaskLandscapeRight; } return UIInterfaceOrientationMaskPortrait;}- (NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskPortrait |UIInterfaceOrientationMaskLandscapeLeft |UIInterfaceOrientationMaskLandscapeRight;}- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ return UIInterfaceOrientationPortrait;}
其次,跳转方法
- (void)TapMovieTableCellDelegate:(NSString *)urlString{ NSURL *videoUrl = [NSURL URLWithString:urlString]; XRDCustomerViewController *xrd = [[XRDCustomerViewController alloc] initWithContentURL:videoUrl]; // 缓冲播放 [xrd.moviePlayer prepareToPlay]; // 播放 [xrd.moviePlayer play]; // 跳转方式 [xrd setModalTransitionStyle:UIModalTransitionStyleCrossDissolve]; // 弹出播放器 [self presentMoviePlayerViewControllerAnimated:xrd];}
最后XRDCustomerViewController.h文件:
#import <MediaPlayer/MediaPlayer.h>@interface XRDCustomerViewController : MPMoviePlayerViewController@end
XRDCustomerViewController.m文件:
#import "XRDCustomerViewController.h"@implementation XRDCustomerViewController- (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated];}-(void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; delegate.allowRotation = YES;}- (void)viewWillDisappear:(BOOL)animated{ AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; delegate.allowRotation = NO;}- (void)viewDidLoad{ [super viewDidLoad]; // 该类继承于MPMoviePlayerViewController}@end
如果仍然没有弄成功,请QQ联系:714700382
0 0
- IOS视屏播放过程中横竖屏切换
- iOS视频播放横竖屏切换技巧
- iOS 中横竖屏切换
- ios横竖屏切换
- IOS横竖屏切换
- IOS 横竖屏切换
- iOS横竖屏切换
- ios 切换横竖屏
- iOS 横竖屏切换
- iOS 横竖屏切换
- iOS横竖屏切换
- iOS 横竖屏切换
- iOS Swift3.0实现视频播放横竖屏切换效果
- ios播放器横竖屏切换的问题
- iOS播放器横竖屏切换的实现
- Android中WebView播放网上视频,横竖屏切换
- iOS 6横竖屏切换
- 横竖屏切换问题ios
- 卡尔曼滤波器学习之一最小二乘法
- html5
- 2016蓝桥杯假期任务之《错误票据》
- js1
- 如何直接维护一个已经存在的透明表(转账表)
- IOS视屏播放过程中横竖屏切换
- Android 从前台切换到后台
- JS2
- 【TCP】TCP的几个状态 (SYN, FIN, ACK, PSH, RST, URG)
- 用dumpbin.exe工具查看DLL
- java运算符及二进制、八进制、十六进制
- Hadoop Streaming编程实例
- http://blog.csdn.net/liulin_good/article/details/6213815
- Spark设计理念与基本架构