Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9221465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:35:06+00:00 2026-06-18T03:35:06+00:00

I am writing an app for the iPhone that will play some movies utilizing

  • 0

I am writing an app for the iPhone that will play some movies utilizing MPMoviePlayerViewController. So far I have gotten it to play movies, however it is throwing some errors in the debugger that all start with CGContext. I have wracked my brain in trying to fix it. Here are the details of my code:

.h file:

#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface MovieViewController : UIViewController {
    MPMoviePlayerViewController *playerController;
}

-(IBAction) playMovie:(id)sender;

.m file:

@interface MovieViewController ()
@end
@implementation

-(IBAction)playMovie:(id)sender {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
                                     pathForResource:@"moviename" ofType:@"mp4"]];
playerController =  [[MPMoviePlayerViewController alloc]
                     initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:playerController];
playerController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[playerController.moviePlayer play];
playerController = nil; 
}

When I run the program the movie will play, however when the code executes the line: playerController = [[MPMoviePlayerViewController alloc] initWithContentURL:url]; the following errors occur:

<Error>: CGContextSaveGState: invalid context 0x0
<Error>: CGContextClipToRect: invalid context 0x0
<Error>: CGContextTranslateCTM: invalid context 0x0
<Error>: CGContextDrawShading: invalid context 0x0
<Error>: CGContextRestoreGState: invalid context 0x0

I do know that invalid context 0x0 means that those specific variables do not have a value, but I have no idea how to remedy this. Any help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:35:07+00:00Added an answer on June 18, 2026 at 3:35 am

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an iPhone app, and I have a remote server that will
I'm writing an iPhone App that relies on getting the device location. Management have
I have an iPhone app that I am writing and it has 2 targets
I have a 32bit iMac that I am writing an iPhone app in Xcode
I'm writing an iPhone app (which will be my first ios app) that has
I'm a newbie iPhone developer, writing an app that will kind of be the
Right now i'm writing an iPhone app that will interact with a network, and
I am writing a map-based iphone app that will send the current location data
I'm writing an app that will allow iPhone users to login to their accounts.
I am writing an iPhone app that allows you to browse images in one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.