views:

165

answers:

1

How can I play a movie in my app? I tried using this code, but xcode gives me this error:

NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"welcome" ofType:@"mp4"];
NSURL  *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
movieView = [[MPMoviePlayerViewController alloc] initWithContentURL: movieURL];
theMovie = [movieView moviePlayer];
theMovie.scalingMode = MPMovieScalingModeAspectFit;
theMovie.fullscreen = TRUE;
theMovie.controlStyle = MPMovieControlStyleNone;
theMovie.shouldAutoplay = TRUE;

[[[UIApplication sharedApplication] keyWindow] addSubview: movieView.view];   

ERROR

ld: warning: in /Users/Rushil/Documents/StickDeath/MediaPlayer.framework/MediaPlayer, missing required architecture i386 in file
Undefined symbols:
  "_OBJC_CLASS_$_MPMoviePlayerViewController", referenced from:
      objc-class-ref-to-MPMoviePlayerViewController in StickDeathViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
+1  A: 

Please notice that MPMoviePlayerViewController only available on iOS3.2 and later

Double check for that, I think that is the issue. More here about MPMoviePlayerViewController

vodkhang
I know it is only for ios 3.2 and later, but I have set my deployment target to 4.0, so that it my app will only run on 4.0 devices(just to test this) and it still doesn't work
Rushil
To make this work do you have to manually add another view controller or something?
Rushil
I think you set it wrongly. It is a build/compile error, not a runtime error so you don't need to add another viewcontroller. Xcode just doesn't find the class
vodkhang
set it wrongly? But what could I have set wrong? I checked the deployment target, and remimported the mediaplayer framework. Neither of which solved my issue
Rushil
It looks like you were right, I started a new project, and it didn't throw the error. However, know it shows this:Method definition for my ibaction not foundCode:-(IBAction)m:(id)sender;and then in my .m-(IBAction)m{code}and it still shows the error even after i comment out all the code inside the ibaction!
Rushil
in your .m file, you forgot the argument m:(id)sender
vodkhang
Thanks! I can't believe I was so stupid! I knew it was something small like that!!
Rushil