objective c - When my movie is finished to play, the app crashes -


I tried to launch a movie by clicking on a button. When I click on the movie player and work fine the film runs to the end and the movie player disappears. After this disappears, my app crashes ...

I use my visual controller in the tab bar with this code:

  - (Zero) Movie PlayBackDidFinish: (NSNotification *) An Information {MPMoviePlayerController * Player = [An Information Object]; [Player setfullscreen: no animated: yes]; [Player.view removeFromSuperview]; [Player stops]; Player.initialPlaybackTime = -1.0; [[NSNotificationCenter defaultCenter] Deletion Observer: Own Name: MPMVplayerplaybackDefinition Object: Player]; [Player release]; Player = nil; } - (IBAction) Play video: (UIButton *) playButton {NSString * url = [[NSBundle main bundle] pathForResource: @ "Teaser 04" type: @ "mov"]; MPMoviePlayerController * Player = [[MP3 MPV Player Controller Light] initWithContentURL: [NSUr file URLWithPath: url]]; Player.shouldautoplay = yes; Player.view.frame = CGRectMake (0, 44., self.view.bounds.size.width, self.view.bounds.size.height-44); [[NSNotificationCenter defaultCenter] addObserver: Self Selector: @Selector (Movie PLAYBackDidFinish :) Name: MPMoviePlayerPlaybackDidFinishNotification Object: Player]; [Self.view addSubview: player.view]; [Player's game]; }   

I do not know what I'm doing wrong I just want to configure a button that starts the video and when the video ends, the movie player view disappears And the app comes back to my beginning. Xib

Thank you for your help

I have found a solution, not me Know that this is the best but for this I am doing this:

  - (zero) movie fix callback: (nsnification) * an information {MPVPlayer controller * Player = [A Information object]; [[NSNotificationCenter defaultCenter] Deletion Observer: Own Name: MPMVplayerplaybackDefinition Object: Player]; [Player.view removeFromSuperview]; [Player stops]; [Player release];   

}

  - (IBAction) Play video: (UIButton *) playButton {NSString * url = [[NSBundle mainBundle] pathForResource: @ "Teaser 04 "OfType: @" mov "]; MPMoviePlayerController * Player = [[MP3 MPV Player Controller Light] initWithContentURL: [NSUr file URLWithPath: url]]; [[NSNotificationCenter defaultCenter] addObserver: Self selector: @sillector (moviefield callback :) Name: MPMVplayerplaybackDefinition Object: Player]; Player.view.frame = CGRectMake (0, 0, 950, 600); [Self.view addSubview: player.view]; [Player's game];   

}

Comments