iOS - Playing more than one video

I am using this code with the MediaPlayer framework to play a video:

-(void)GrommeVideoExcerpt1
{
NSURL *url1 = [NSURL fileURLWithPath:[[NSBundle mainBundle]
                                     pathForResource:@"GrommeVideoExcerpt1" ofType:@"mp4"]];
grommePlayer1 =  [[MPMoviePlayerController alloc]
                  initWithContentURL:url1];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:grommePlayer1];

grommePlayer1.controlStyle = MPMovieControlStyleDefault;
grommePlayer1.shouldAutoplay = YES;
[self.view addSubview:grommePlayer1.view];
[grommePlayer1 setFullscreen:YES animated:YES];
}

But when I play one video, then navigate to another video and try to play it, the app crashes. It gives me this error:

http://pastebin.com/nUGLXEAi

Answers


The problem here is you are adding a notification for when the video finishes playing, and that notification triggers a method you do not have (moviePlayBackDidFinish:) causing the crash.

You could implement this method or remove the notification, depends what you want to do after the video is done playing i.e. remove a viewController that plays the video, etc.

//Register notification
[[NSNotificationCenter defaultCenter] addObserver:self
                                     selector:@selector(moviePlayBackDidFinish:)
                                         name:MPMoviePlayerPlaybackDidFinishNotification
                                       object:nil];
//Then the method ...
-(void) moviePlaybackDidFinish:(NSNotification *)aNotification{
  [grommePlayer1.view removeFromSuperview];
  grommePlayer1 = nil;
}

Need Your Help

May be error in enclosed text which has TEXT datatype in last column, MySQL Error 1064 occurs

mysql syntax-error mysql-workbench

I am getting the following error in the SQL query below.what can be the possible cause?

Is any method to loading kml in background in html with java script

javascript html html5 google-maps

I trying to loading kml file on map in html but it takes more time to loading kml file on mobile screen