Tutorial :How can I use MPMoviePlayerController within my application?



Question:

I'm having trouble implementing MPMoviePlayerController. I've downloaded and run the MoviePlayer app, and it works fine, but I'm unable to reproduce this functionality in my own app. I have added the MediaPlayer Framework and imported to my app.

Here are the relevant parts of my code:

UITableViewController class:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {      if (indexPath.section==1) {          MyAppDelegate *appDelegate =   (MyAppDelegate *)[[UIApplication sharedApplication] delegate];          [appDelegate initAndPlayMovie:[self localMovieURL]];      }  }  

MyAppDelegate:

-(void)initAndPlayMovie:(NSURL *)movieURL  {      // Initialize a movie player object with the specified URL      MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];      if (mp)      {          self.moviePlayer = mp;          [mp release];                     [self.moviePlayer play];      }  }  

I did some debugging in

- (void) moviePreloadDidFinish:(NSNotification*)notification {     NSLog(@"moviePreloadDidFinish");  }  

and in

- (void) moviePlayBackDidFinish:(NSNotification*)notification {     NSLog(@"moviePlayBackDidFinish");  }  

I noticed that the movie loads correctly and plays, I guess somewhere in the background, for the appropriate amount of time, but I just can't see the Movie Player. The view never changes from my TableViewController!

Any Ideas? Please help!!!


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »