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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:31:48+00:00 2026-05-24T08:31:48+00:00

I created a global variable: MPMoviePlayerController *player; I play the video with the following

  • 0

I created a global variable:

MPMoviePlayerController *player;

I play the video with the following method:

-(IBAction) playMovie: (NSString*) videoName ViedeoType:(NSString*) videoType{

ViewVideoSubview.alpha = 0;

NSString *url = [[NSBundle mainBundle] 
                 pathForResource:videoName 
                 ofType:videoType];


player = 
[[MPMoviePlayerController alloc] 
 initWithContentURL:[NSURL fileURLWithPath:url]];


player.shouldAutoplay =YES;



[ViewVideoSubview addSubview:player.view];



[[NSNotificationCenter defaultCenter] 
 addObserver:self
 selector:@selector(movieFinishedCallback:)                                                 
 name:MPMoviePlayerPlaybackDidFinishNotification
 object:player];

}

and when the video finishes playing by itself the folloing method get’s called:

- (void) movieFinishedCallback:(NSNotification*) aNotification {



    [player.view removeFromSuperview];  //d1
    MPMoviePlayerController *playerParam = [aNotification object];
    [[NSNotificationCenter defaultCenter] 
     removeObserver:self
     name:MPMoviePlayerPlaybackDidFinishNotification
     object:playerParam];  

     [player release];

}

Everything works great so far. The problem is that I have a button that when pressed I need to load another view controller. I am able to load that view controller but the video still plays in the background. I don’t why I get an error when releasing the player. my temporary solution is to stop the video then load the other view controller so that the video does not play in the background.

Another solution that I was thinking of is to play the video 1 second before it finishes playing so that it gets released with the method movieFinishedCallback. I don’t know how I will be able to “fast forward” the video to that point. I am new to objective-c and I don’t know what is the aNotification parameter otherwise I will just call that method with the appropriate parameter.

Let me show you the error that I am getting:

enter image description here
enter image description here

  • 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-24T08:31:49+00:00Added an answer on May 24, 2026 at 8:31 am

    I think your problem lies in the way you are trying to remove an observer in the method movieFinishedCallback

    here you are passing a pointer to your global property player.

    MPMoviePlayerController *playerParam = [aNotification object];
    

    and here you are invocing a method to remove observer for all notifications regarding this object playerParam

    [[NSNotificationCenter defaultCenter] 
     removeObserver:self
     name:MPMoviePlayerPlaybackDidFinishNotification
     object:playerParam];  
    

    Now you get an EXEC_BAD_ACCESS because you are sending a pointer (playerParam) to your player (already released somewhere) to a method (removeObserver) causing an operation of removeObserver to be called on an non-existing object.

    Instead of using

    [[NSNotificationCenter defaultCenter] 
         removeObserver:self
         name:MPMoviePlayerPlaybackDidFinishNotification
         object:playerParam]; 
    

    try

    [[NSNotificationCenter defaultCenter] 
         removeObserver:self
         name:MPMoviePlayerPlaybackDidFinishNotification
         object:nil]; 
    

    Making your object nil will:

    -(void)removeObserver:(id)notificationObserver name:(NSString
    *)notificationName object:(id)notificationSender

    notificationSender …
    When nil, the receiver does not use notification senders as criteria
    for removal.

    More info can be found in NSNotificationCenter Class Reference

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

Sidebar

Related Questions

I'm very confused. I've created a global variable: public LabelField title2 = new LabelField(,
Looking at some old VB 6.0 code we had created a global mFont variable
I created the global temp table. when I execute the code as an individual
I've created a global handler for ajaxSuccess , but I need to be able
I am using my admin panel login script where i have created a global.php
I have a string like following: CREATE GLOBAL TEMPORARY TABLE some_temp_table_name or CREATE GLOBAL
I have a sample file like the following: CREATE GLOBAL TEMPORARY TABLE tt_temp_user_11 (
Assume that I have a global variable user in application....like this: # GET /users.xml
I have created a Variable called myDBManager in my AppDelegate: @interface myAppDelegate : NSObject
I created a module Foo::Prototype with the global variables $A and $B. I want

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.