0

I have the basic MPMoviePlayer code

moviePlayerViewController = [[MPMoviePlayerViewController alloc]initWithContentURL:local_url];
[moviePlayerViewController.view setFrame:CGRectMake(0, 0, 320, 320)];
[[Util get_rootViewController] presentMoviePlayerViewControllerAnimated:moviePlayerViewController];
[moviePlayerViewController.moviePlayer play];
[[Util get_rootViewController].view addSubview:moviePlayerViewController.view];

It's working fine in iPad with 7.0 version. But it has not displayed the video in iOS8 and it is getting audio only.

I tried the answers which have been suggested so far, but still no luck.

Matt Taylor
  • 3,360
  • 1
  • 20
  • 34
Sethu K
  • 41
  • 8
  • `MPMoviePlayerViewController` != `MPMoviePlayerController`. Your code is an odd mixture of both. So step 1 is to decide which one you're trying to use. – user3386109 Sep 11 '15 at 06:23
  • little confusion - you have presented movie player controller then added it's view as subview to other view...!! So eiather add it's view as subview or present its controller. Dont do both – Nayan Sep 11 '15 at 06:26
  • The issue was fixed. Actually the problem is my root controller.. So i have been added one view controller and added the movie player class.it's working fine right now. – Sethu K Sep 14 '15 at 07:06

3 Answers3

0

Try this code:

NSURL *movieURL = [NSURL URLWithString:@"http://example.com/somefile.mp4"];
movieController = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
[self presentMoviePlayerViewControllerAnimated:movieController];
[movieController.moviePlayer play];

Make more clear with this link:"iOS: How to use MPMoviePlayerController"

Community
  • 1
  • 1
Shubham Narang
  • 514
  • 2
  • 14
0

Try this code it works on iOS 8 (personally tested.)

   MPMoviePlayerViewController * moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:local_url];

      moviePlayer.moviePlayer.movieSourceType = MPMovieSourceTypeFile;

      [moviePlayer.moviePlayer setControlStyle:MPMovieControlStyleFullscreen];

      [moviePlayer.view setTranslatesAutoresizingMaskIntoConstraints:YES];

      [self presentMoviePlayerViewControllerAnimated:moviePlayer];
DHEERAJ
  • 1,478
  • 12
  • 32
0

The issue was fixed. Actually the problem is my root controller.. So i have been added one more controller and added the movie player class.it's working fine right now.

Sethu K
  • 41
  • 8