ios9 - 在 iOS9 中弃用 mpmovieplayercontroller 后继续前进的方式

标签 ios9

我有一个代码可以:

    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 的弃用,用于执行上述功能的框架是什么。

最佳答案

使用苹果提供的以下方式。主要使用AVFoundation框架,同时支持画中画功能以支持最新的iOS 9多任务处理功能。

Apple 文档

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

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 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 - 在 iOS9 中弃用 mpmovieplayercontroller 后继续前进的方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30953342/

相关文章:

ios - kSecAttrAccessibleAlways 在 iOS 9 中被弃用

ios - 黑色条纹显示在旧项目的 View 中

ios - 异常 EXC_BAD_INSTRUCTION 在 swift 2 中播放音频

swift - 如何获取我的位置数据并将其放入 iMessage 的变量中?

ios - UIViewController 类型的值在 Xcode 7 更新后没有成员 topViewController

swift - NavigationBar 高度在返回纵向时发生变化

ios - 自定义 TableViewCell 内容在 ios9 xcode7 上不可见

ios - Facebook 分享内容在 iOS 9 中只分享 URL

ios - 根据预览 View Controller 的 PHAsset 大小计算 preferredContentSize

ios - 在 UISegmentedControl 中换行文本 (iOS 9+)