MPMoviePlayerController on large videos causes massive memory spike, and a level 1 memory warning
- by Shizam
When viewing images my application hums along nicely with low memory consumption, once I try to watch a video using MPMoviePlayerController memory usage spikes way up, dwarfing the previous memory graph and if I play the video it causes a 'memory warning. Level=1' message. The video files (mp4) aren't even that big, 40MB or so, and it doesn't matter if I play the file streamed from a URL or loaded from a local file, actually the memory spike is even worse if I try to stream it.
Here is the code I use to create the player:
if (_photo.videoPath != nil) {
_movieViewController=[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:_photo.videoPath]];
} else {
_movieViewController=[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:_photo.videoURL]];
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoMetaListener:)
name:MPMovieDurationAvailableNotification object:_movieViewController.moviePlayer];
_movieViewController.moviePlayer.scalingMode=MPMovieScalingModeAspectFit;
_movieViewController.moviePlayer.shouldAutoplay = YES;
_movieViewController.moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
Anybody else running into issues playing video? Also I checked for leaks, there are none reported.