iPad play video when button tapped

Discussion in 'iOS Programming' started by Michael H, Jul 20, 2010.

  1. macrumors newbie

    Jan 26, 2008
    I am trying to accomplish on an iPad having a Menu view that has a button and when you tap button .mov clip will play and when it ends Menu view will re-appear. When I start application the Video view appears not the Menu view. You can tap the play button and the video play just fine and at end a blank whit screen appears. Here are the .h & .m files. Please help.


    #import <UIKit/UIKit.h>
    #import <MediaPlayer/MediaPlayer.h>
    @interface mainMenuViewController : UIViewController {
    	MPMoviePlayerController *playerViewController;	
    - (IBAction) playVideo;

    #import "mainMenuViewController.h"
    @implementation mainMenuViewController
    - (void)viewDidLoad {
    	NSString *url = [[NSBundle mainBundle] pathForResource:@"BeachCompilation" ofType:@"mov"];
    	MPMoviePlayerViewController *playerViewController = [[MPMoviePlayerViewController alloc]
    														 initWithContentURL:[NSURL fileURLWithPath:url]];
    	[[NSNotificationCenter defaultCenter]
    	 object:[playerViewController moviePlayer]];
    WARNING - Local declaration of ‘playerViewContoller’ hides instance variable	
    	[self.view addSubview:playerViewController.view];
    WARNING - Local declaration of ‘playerViewContoller’ hides instance variable
    	[super viewDidLoad];
    - (IBAction) goToBeachMenu: (NSURL *) url {
    	//NSLog(@"button works");
    	MPMoviePlayerController *player = [playerViewController moviePlayer];
    WARNING - ‘MpmoviePlayerController’ may not respond to ‘-moviePlyer’
    	[player play];
  2. Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    1. Name the local playerViewController variable from the viewDidLoad something different than the instance variable of the same name.

    2. You sure you want to add the subView in viewDidLoad and not in the button's action?

    3. What does the code for the movieFinishedCallback: look like?

Share This Page