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

  • SEARCH
  • Home
  • 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 6813183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:32:25+00:00 2026-05-26T20:32:25+00:00

This is not the No video, audio only problem . It’s just the opposite

  • 0

This is not the No video, audio only problem. It’s just the opposite.
The problem arises when using iOS 5.0. iPads running 4.3 or lower play the same video files flawlessly.

since iOS 5 changed the way stuff is initialized for MPMoviePlayerControllers, I had to do some SDK based programming in order to get the video to be displayed. Before implementing the snippet I’m showing next, the video and it’s controls won’t even show up on the screen. The controller would only show a black square with the size and origin of given CGRect frame.

The way I handle it is the following:

The video files are located on the documents folder. So the NSURL has to be initialized as fileURLWithPath. Once that’s done, I proceed to initialized the controller with a given frame. Since it wouldn’t work otherwise, the view will only add the player once it has changed its loadState. That’s achieve by subscribing to a notification. the subscriber selector performs the addition of the controller’s view to the parent view on the main thread since the notification could be handled from other threads.

Initializing and adding video to the view:

-(void)addVideo:(NSString*) videoName onRect:(CGRect)rect {

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    iPadMagazineAppDelegate *appDelegate = GET_APP_DELEGATE;
    NSArray *dirArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *dirName = [dirArray objectAtIndex:0];

    // get directory name for this issue
    NSURL *baseURL; 

    /* 
     BUGFIX: Video does not work on iOS 5.0

     */
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"5.0")){
        baseURL = [[NSURL fileURLWithPath:dirName]URLByAppendingPathComponent:[appDelegate.currentIssue getIssueDirectoryName ]];
    }else {
        baseURL = [[NSURL URLWithString:dirName] URLByAppendingPathComponent:[appDelegate.currentIssue getIssueDirectoryName]];
    }

    /* end  BUGFIX: Video does not work on iOS 5.0 */

    NSURL *videoURL = [baseURL URLByAppendingPathComponent:videoName];    


    MPMoviePlayerController * movieController= [[MPMoviePlayerController alloc]initWithContentURL:videoURL];

    // set frame for player
    movieController.view.frame = rect;

    // set  auto resizing masks
    [movieController.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];

    // don't auto play.
    [movieController setShouldAutoplay:NO];

    [movieController setUseApplicationAudioSession:YES];

    /*
     BUGFIX: Video does not work on iOS 5.0
     */
    if (SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(@"5.0")) {
        [movieController prepareToPlay];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadVideo:) name:MPMoviePlayerLoadStateDidChangeNotification object:movieController];  
    }else {
        [pdfView addSubview:movieController.view];
        [pdfView bringSubviewToFront: movieController.view];
    }

    /* end  BUGFIX: Video does not work on iOS 5.0 */

    [_moviePlayerViewControllerArray addObject:movieController];
    [movieController release];
    [pool release];
}

notification handler:

-(void)loadVideo:(NSNotification*)notification {

    for (MPMoviePlayerController *movieController in _moviePlayerViewControllerArray) {

        if (movieController.loadState != MPMovieLoadStateUnknown) {


            [pdfView performSelectorOnMainThread:@selector(addSubview:) withObject:movieController.view waitUntilDone:YES];
            [pdfView performSelectorOnMainThread:@selector(bringSubviewToFront:) withObject:movieController.view waitUntilDone:YES];
            [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerLoadStateDidChangeNotification object:movieController];
        }
    }

}

Thank you for reading this huge question. I appreciate your answers.

cheers.

  • 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-05-26T20:32:25+00:00Added an answer on May 26, 2026 at 8:32 pm

    Apparently there’s a bug, but it’s not related to the MPMoviePlayerController, but to iOS 5 itself.

    My iPad was muted from the switch but still played audio from iPod app anyway so I didn’t realized that it was that way, so MPMoviePlayerController was fine, but part of the OS did not notice that the iPad was muted.

    I’ve filed the corresponding bug on Apple’s bug tracker. Bug ID# 10368531.

    I Apologize if I’ve wasted your time.

    UPDATE: Got feedback from apple for the bug. It’s expected behavior. :\

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

Sidebar

Related Questions

In chrome (7.0.517.44) I am using the <video> tag and the audio will only
I know this is not programming related, but I have a scenario. Each video
<video id=myVideo src=2.mp4 controls= tabindex=0>decoder not found</video> this code show ' decoder not found'
I am working On Audio/Video capturing from a Web Camera and this is targeted
I am trying to display video file bt it is not being displayed only
I'm not sure if Youtube is the only website with this technology, but content
Sorry for this not being a real question, but Sometime back i remember seeing
I ask this not to start anything negative. Rather, after looking at ASP.NET MVC
why is this not ok? aContract = function(){}; aContract.prototype = { someFunction: function() {
Why does this not work? Do I not understand delegate covariance correctly? public delegate

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.