iOS9中mpmovieplayercontroller弃用后的处理方法 [英] Way to go ahead after mpmovieplayercontroller deprecation in iOS9

查看:271
本文介绍了iOS9中mpmovieplayercontroller弃用后的处理方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个执行以下操作的代码:

I have a code which does:

    self.video = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:url]];
    self.video.movieSourceType = MPMovieSourceTypeStreaming;
    [[self.video view] setFrame:[[self view] bounds]];
    [self.view addSubview:self.video.view];
    [self.video play];

它基本上会加载一个URL并开始播放它.随着MPMoviePlayerController的弃用,用于执行上述功能的框架是什么.

It basically loads a url and starts playing it. With the deprecation of MPMoviePlayerController what is the framework to be used to do the above functionality.

推荐答案

使用Apple提供的以下方法.基本上使用AVFoundation框架,它还支持画中画功能,以支持最新的iOS 9多任务处理功能.

Use below ways provided by Apple. Basically using AVFoundation framework, Also it support picture in picture feature to support latest iOS 9 multi tasking feature.

Apple文档

AVKit框架提供了AVPlayerViewController类,该类 自动为您的用户显示一个画中画按钮.

The AVKit framework provides the AVPlayerViewController class, which automatically displays a PiP button for your users.

如果您使用AVKit支持PiP,但想为特定视频选择不使用PiP,请分配 播放器视图控制器的否"值 allowPictureInPicturePlayback属性.

If you support PiP using AVKit but want to opt out of PiP for a particular video, assign a value of NO to the player view controller’s allowsPictureInPicturePlayback property.

AVKit还提供了AVPictureInPictureController类,您可以通过该类 可以与AV Foundation中的AVPlayerLayer类一起使用.用这个 如果您想提供自己的视图控制器和自定义 视频播放的用户界面.

AVKit also provides the AVPictureInPictureController class, which you can use with the AVPlayerLayer class from AV Foundation. Use this approach if you’d like to provide your own view controller and custom user interface for video playback.

这篇关于iOS9中mpmovieplayercontroller弃用后的处理方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆