MPMoviePlayerController on large videos causes massive memory spike, and a level 1 memory warning

Posted by Shizam on Stack Overflow See other posts from Stack Overflow or by Shizam
Published on 2010-04-11T18:46:44Z Indexed on 2010/04/11 18:53 UTC
Read the original article Hit count: 811

Filed under:
|
|
|
|

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.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk