iphone MPMoviePlayerViewController CGContext Errors

耗尽温柔 提交于 2019-12-03 07:22:36

I was having the same issue. Merely saying this:

MPMoviePlayerViewController* mpvc = 
    [[MPMoviePlayerViewController alloc] initWithContentURL: m];

was causing these invalid context error messages. The view controller's view (the fullscreen player) did appear when presented, and played the movie no problem; the only issue was these error messages, which I didn't want showing up in the console.

Taking a hint from Norman's solution, I simply wrapped the call in an artificial drawing context, like this:

UIGraphicsBeginImageContext(CGSizeMake(1,1));
MPMoviePlayerViewController* mpvc = 
    [[MPMoviePlayerViewController alloc] initWithContentURL: m];
UIGraphicsEndImageContext();

It's silly, but it works.

I think the error messages are a bug in MPMoviePlayerViewController

They don't seem to be fatal, although I've made them go away by adding a call to UIGraphicsBeginImageContext(self.view.frame.size); in both readyPlayer() and viewDidLoad().

I also added a UIGraphicsEndImageContext() to dealloc() to clean up the generated contexts.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!