ios - 'MPMoviePlayerController' 已弃用 : first deprecated in iOS 9. 0

标签 ios objective-c ios9 mpmovieplayercontroller deprecated

<分区>

已经有人快速回答了这个问题
MPMoviePlayerController' is deprecated in swift我想要这个在 Objective-C 中。

我收到这个警告

'MPMoviePlayerController' is deprecated: first deprecated in iOS 9.0

这是我的代码:

MPMoviePlayerController* _moviePlayer;
_moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:contentURL];
_moviePlayer.shouldAutoplay = YES;
[self.view addSubview:_moviePlayer.view];
[_moviePlayer setFullscreen:YES animated:YES];

最佳答案

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

#import <AVKit/AVKit.h>
#import <AVFoundation/AVFoundation.h>  

2) 我将我的代码替换为

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

    [self presentViewController:_moviePlayer1 animated:YES completion:^{
        [_moviePlayer1.player play];
    }];  

我希望它能帮助遇到这个问题的人。

关于ios - 'MPMoviePlayerController' 已弃用 : first deprecated in iOS 9. 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43782248/

上一篇:ios - 如何以编程方式检查 NSMicrophoneUsageDescription

下一篇:ios - 不支持的操作 - 不允许应用程序监听设备锁定通知

相关文章:

javascript - 使用 Phonegap 的离线自定义平铺 Google map ?

ios - 记录然后播放UIApplication的所有UIEvent的方法

iphone - whatsapp 登录如何在 iphone 上工作..?

ios - UIImagePickerController 以大写字母 "USE_PHOTO"、 "RETAKE"和图库图像 "CAMERA_ROLL"显示文本?

xcode - 我们可以在模拟器中测试Apple pay吗

ios - ViewController.xib 未打开

ios - 快速登录

ios - UILabel具有自动布局的丑陋旋转动画

ios - awakeFromNib 未在自定义单元格类中调用,因为 IBOutlets 为零

facebook - iOS 9 - Facebook 无法打开已安装的 iOS 应用