views:

560

answers:

2

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.

A: 

Yes, I'm receiving this error as well. But I'm only trying to load a small 7MB file from our website. My problem seems to be one step further, as the video will not even play. The video is loaded, and you can search through the video with the scrubber bar, but it will not play. If you click the play button it immediately stops. I have been fighting this problem for a week now, and not finding much in my searches online. I very desperately need to figure out a way to play this video. BTW, this is a universal APP, just having issues on the iPad side of things. My creation of the MPMoviePlayerViewController is basically identical to yours listed above. The video plays flawlessly in the simulator, but will absolutely not play on the device! I've even re-encoded the video several times with various settings to make sure that wasn't the problem. The video I'm currently using is 480x360, H.264 Baseline L3.0, with AAC/LC Audio at 44.1KHz. These all fall within the specs for video playback on both the iPhone and iPad. If I've left out any key piece of information, let me know, but I wanted to try to provide as much as possible. I hope someone out there can shed some light on this. Thanks.

Symo
It turned out that on the device the memory is properly released so it must be a bug in the simulator. As for your 'it won't play on the device' problem, I had this problem for the first time last night, videos wouldn't play on my CEO's iPad but played fine on both my iPads. Turned out if I did a hard reset on his iPad it fixed everything, try that.
Shizam
A: 

Turns out this is a bug in the simulator. On the device the memory usage is normal.

Shizam