82 MPMoviePlayerViewController基本使用

来源:互联网 发布:远程连接linux常用工具 编辑:程序博客网 时间:2024/06/06 08:36
1>视频播放:    // 播放视频(流媒体)    NSString *videoUrl = [NSString stringWithFormat:@"http://192.168.1.200:8080/MJServer/%@", video.url];    HMMoviePlayerViewController *playerVc = [[HMMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:videoUrl]];    [self presentMoviePlayerViewControllerAnimated:playerVc];    // 只能全屏播放//    MPMoviePlayerController; // 可以随意控制播放器的尺寸
2>在进入后台后MPMoviePlayerViewController会自动销毁,所以自定义HMMoviePlayerViewController,移除通知:- (void)viewDidLoad{    [super viewDidLoad];    // 移除程序进入后台的通知    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];}并且在HMMoviePlayerViewController实现横屏播放:/** *  控制当前控制器支持哪些方向 *  返回值是UIInterfaceOrientationMask* */- (NSUInteger)supportedInterfaceOrientations{    return UIInterfaceOrientationMaskLandscape;}
0 0
原创粉丝点击