Way to go ahead after mpmovieplayercontroller depr

2019-05-17 07:36发布

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];

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.

标签: ios9
1条回答
来,给爷笑一个
2楼-- · 2019-05-17 07:45

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 Documentation

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.

查看更多
登录 后发表回答