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 8112275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:26:15+00:00 2026-06-06T02:26:15+00:00

I have been browsing through Google for various explanations but I STILL couldn’t figure

  • 0

I have been browsing through Google for various explanations but I STILL couldn’t figure out when this code fires the screen is pitch black. Anyone able to spot a mistake?

UPDATE

- (IBAction)playVideo:(id)sender {
    NSURL *videoUrl = [[DataStore singletonInstance] getVideoUrl:self withUuid:self.eventDetailVC.event.uuid];
    if ([videoUrl checkResourceIsReachableAndReturnError:nil] == NO) {
        NSLog(@"Video doesn't not exist.");
        return;
    }
    MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:videoUrl];
    [[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(moviePlayBackDidFinish:) 
                                             name:MPMoviePlayerPlaybackDidFinishNotification 
                                               object:player];
    [previewView addSubview:player.view];
    player.view.frame = previewView.bounds;
    player.controlStyle = MPMovieControlStyleDefault;
    [player play];
}

- (void)moviePlayBackDidFinish:(NSNotification*)notification {
    NSLog(@"moviePlayBackDidFinish: called");
    MPMoviePlayerController *player = [notification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification 
                                                  object:player];
    // Checking for errors
    NSDictionary *notiUserInfo = [notification userInfo];
    if (notiUserInfo != nil) {
        NSError *errorInfo = [notiUserInfo objectForKey:@"error"];
        if ([[errorInfo domain] isEqualToString:@"MediaPlayerErrorDomain"]) {
            UIAlertView *notice = [[UIAlertView alloc] initWithTitle:@"Error" 
                                                             message:[errorInfo localizedDescription] 
                                                            delegate:self 
                                                   cancelButtonTitle:@"OK" 
                                                   otherButtonTitles:nil];
            [notice show];
            return;
        }
    }
    // Remove from view
    [player.view removeFromSuperview];
    [player stop];
}

FYI moviePlayBackDidFinish is NOT called at all. I don’t know why.

  • 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-06T02:26:16+00:00Added an answer on June 6, 2026 at 2:26 am

    Create property for MPMoviePlayerController, because you retain view after adding it as subview, but not retain controller.

    @property (strong, nonatomic) MPMoviePlayerController *player;
    
    ...
    
    @synthesize player = _player;
    
    ...
    
    - (IBAction)playVideo:(id)sender
    {
        NSURL *videoUrl = [[DataStore singletonInstance] getVideoUrl:self withUuid:self.eventDetailVC.event.uuid];
        if ([videoUrl checkResourceIsReachableAndReturnError:nil] == NO)
        {
            NSLog(@"Video doesn't not exist.");
            return;
        }
        self.player = [[MPMoviePlayerController alloc] initWithContentURL:videoUrl];
        [[NSNotificationCenter defaultCenter] addObserver:self 
                                                 selector:@selector(moviePlayBackDidFinish:) 
                                                     name:MPMoviePlayerPlaybackDidFinishNotification 
                                                   object:nil];
        [previewView addSubview:_player.view];
        _player.view.frame = previewView.bounds;
        _player.controlStyle = MPMovieControlStyleDefault;
        [_player play];
    }
    
    - (void)moviePlayBackDidFinish:(NSNotification*)notification
    {
        NSLog(@"moviePlayBackDidFinish: called");
        [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification 
                                                      object:nil];
        // Checking for errors
        NSDictionary *notiUserInfo = [notification userInfo];
        if (notiUserInfo != nil)
        {
            NSError *errorInfo = [notiUserInfo objectForKey:@"error"];
            if ([[errorInfo domain] isEqualToString:@"MediaPlayerErrorDomain"])
            {
                UIAlertView *notice = [[UIAlertView alloc] initWithTitle:@"Error" 
                                                                 message:[errorInfo localizedDescription] 
                                                                delegate:self 
                                                       cancelButtonTitle:@"OK" 
                                                       otherButtonTitles:nil];
                [notice show];
                return;
            }
        }
        // Remove from view
        [_player.view removeFromSuperview];
        [_player stop];
        self.player = nil;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been browsing SO and various other sites to find out whether this
I have been browsing this site for the answer but I'm still a little
I have tried contacting tech support with this question, but it has been over
I have been browsing the Google Plus APIs lately and I can't seem to
I have been browsing the reference section on Android.com and couldn't quite find the
I have been browsing the apple docs and stackoverflow for a while now, but
I have been browsing the web looking for caching information but cannot find anything
Probably a simple question, but I've been browsing now for 30 mins and STILL
Possible Duplicate: What is a dependency property? I have been browsing through the net
I have been browsing these iOS Cocoa controls and looking to test out a

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.