I'm wondering if there is some method to play video with retina resolutoion (2048x1536) for iPad. I'm developing an app that can play video full screen with a MPMoviePlayerController but it can't play video with iPad retina resolution. From the documentation:
Supported Formats This class plays any movie or audio file supported in iOS. This includes both streamed content and fixed-length files. For movie files, this typically means files with the extensions .mov, .mp4, .mpv, and .3gp and using one of the following compression standards:
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) If you use this class to play audio files, it displays a white screen with a QuickTime logo while the audio plays. For audio files, this class supports AAC-LC audio at up to 48 kHz, and MP3 (MPEG-1 Audio Layer 3) up to 48 kHz, stereo audio.
It ISN'T true!!! I can play H.264 video (960x640) on iPhone and 1024x768 video on ipad...
So: How can I play video with iPad retina resolution? Is it possible? There are other ways to play video on iOS apps without MPMoviePlayerController?
According to my tests, it is possible to play files in 2048x1536 on the retina iPads, using an H264 encoding. The trick is Handbrake (or FFMPEG) to generate the file with those settings. On this page, you'll find some 1536p video files that can be used to test the playback at this resolution.
By the way, a good thing I suggest when handling local videos is to embed only "semi-retina" resolution videos. By semi-retina, I mean 1536x1152. This gives a bit more information than the non-retina resolution, so the video is a bit clearer on retina iPads. And it is good and small enough to be played on any iOS device older than the iPhone 3GS. So you only have to include one video for all devices.
The iPad retina is capable of displaying 1080p video content. This format is compatible with a variety of resolutions, but is most typically defined as 1920 x 1080. This is also the size of video shot with the built in camera, so clearly it can be played back and is larger than the documentation states as the acceptable size.
I was able to verify this with the following code. Create a basic single view project and add a video file into the Supporting Files group.
ViewController.h
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface CDTViewController : UIViewController{
MPMoviePlayerController *moviePlayer;
}
-(IBAction) playMovie;
@end
ViewController.m
@implementation CDTViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
-(void)playMovie {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"IMG_3803" ofType:@"MOV"]];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
if ([moviePlayer respondsToSelector:@selector(loadState)]) {
[moviePlayer setControlStyle:MPMovieControlStyleEmbedded];
[moviePlayer setFullscreen:NO];
[moviePlayer prepareToPlay];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerLoadStateDidChange:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
}
}
- (void)moviePlayerLoadStateDidChange:(NSNotification *)notification {
if ([moviePlayer loadState] == MPMovieLoadStateStalled) {
//handle stall
} else if([moviePlayer loadState] != MPMovieLoadStateUnknown) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
[[moviePlayer view] setFrame:self.view.bounds];
[[self view] addSubview:[moviePlayer view]];
[moviePlayer play];
}
}
@end
don't forget to add MediaPlayer.framework to your project. This example assumes a play button in the xib file that has it;s touchUpInside event attached to the playMovie IBAction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With