开发者

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

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];
        _movieViewControlle开发者_如何学Cr.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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜