prashant
prashant

Reputation: 1920

MPMoviePlayerViewController not playing the video mp4

https://dl.dropboxusercontent.com/u/52719649/69090d547c8d47dd27b6d271649c59ae.mp4

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"SampleVideo.mp4"];
NSURL *url = [NSURL fileURLWithPath:path];
self.controller = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[self.controller.moviePlayer setControlStyle:MPMovieControlStyleDefault];
[self presentMoviePlayerViewControllerAnimated:self.controller];
[self.controller.moviePlayer play];

Upvotes: 0

Views: 577

Answers (2)

holex
holex

Reputation: 24041

you need to recompress the video as the current compression is incorrect:

  • H.264 Main Profile Level 4.0 video

here is a guidance form Apple:

  • H.264 Baseline Profile Level 3.0 video, up to 640 x 480 at 30 fps. (The Baseline profile does not support B frames.)
  • MPEG-4 Part 2 video (Simple Profile)

the audio might need to be changed according to:

(...) this class supports AAC-LC audio at up to 48 kHz, and MP3 (MPEG-1 Audio Layer 3) up to 48 kHz, stereo audio.

for MPMoviePlayerController (Class Reference in Apple's Documentation).

Upvotes: 1

user4657588
user4657588

Reputation:

You should use AVPlayer and AVPlayerViewController instead. Follow this simple guide in order to play videos natively in your app:

http://www.techotopia.com/index.php/IOS_8_Video_Playback_using_AVPlayer_and_AVPlayerViewController

Upvotes: 0

Related Questions