3

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];
Mihir Oza
  • 2,768
  • 3
  • 35
  • 61
  • 1
    And did you look at the doc https://developer.apple.com/reference/mediaplayer/mpmovieplayercontroller that tell you what kind of object you may use to replace it? – Larme May 04 '17 at 12:17
  • 1
    I downvoted because the answer is in the documentation and can be easily found. You would have shown code of tries with `AVPlayerViewController` or `AVPictureInPictureController`, I wouldn't have done so. Also, in the linked question, there are 5/6 lines, which are not really complexe as the methods names are almost the same as the one in Objective-C – Larme May 04 '17 at 12:32
  • No you cant say duplicate because it's in swift language and I mentioned objective-c in tag. I don't know swift, Now how to implement???? – Mihir Oza May 04 '17 at 12:41
  • 1
    http://stackoverflow.com/questions/36044314/avplayerviewcontroller-not-loading-remote-url then ? – Larme May 04 '17 at 12:44
  • 2
    The language is completely irrelevant here. This is a question about the framework. – jscs May 05 '17 at 01:31

1 Answers1

10

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 .

Mihir Oza
  • 2,768
  • 3
  • 35
  • 61