不推荐使用'MPMoviePlayerController':首先在iOS 9.0中弃用

Mih*_*Oza 0 objective-c deprecated mpmovieplayercontroller ios ios9

已经有人在swift中回答这个问题
MPMoviePlayerController'在swift中被弃用了我想在Objective-C中使用它.

我收到了这个警告

不推荐使用'MPMoviePlayerController':首先在iOS 9.0中弃用

这是我的代码:

MPMoviePlayerController* _moviePlayer;
_moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:contentURL];
_moviePlayer.shouldAutoplay = YES;
[self.view addSubview:_moviePlayer.view];
[_moviePlayer setFullscreen:YES animated:YES];
Run Code Online (Sandbox Code Playgroud)

Mih*_*Oza 7

在@Larme的帮助下,我解决了我的问题.
1)我添加了两个框架

#import <AVKit/AVKit.h>
#import <AVFoundation/AVFoundation.h>  
Run Code Online (Sandbox Code Playgroud)

2)我用我的代码替换

AVPlayerViewController * _moviePlayer1 = [[AVPlayerViewController alloc] init];
    _moviePlayer1.player = [AVPlayer playerWithURL:_img.contentURL];

    [self presentViewController:_moviePlayer1 animated:YES completion:^{
        [_moviePlayer1.player play];
    }];  
Run Code Online (Sandbox Code Playgroud)

我希望它能帮助谁面对这个问题.