我有一个代码可以:
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/