'MPMoviePlayerController' is deprecated: first deprecated in iOS 9.0

6.7k Views Asked by At

Already someone answer this question in swift
MPMoviePlayerController' is deprecated in swift I want this in Objective-C.

I am getting this warning

'MPMoviePlayerController' is deprecated: first deprecated in iOS 9.0

Here is my code :

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

There are 1 best solutions below

2
Mihir Oza On BEST ANSWER

With the help of @Larme I resolved my Issue.
1) I added two frameworks

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

2) I replace my code with

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

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

I hope it will help who ever face this issue .