views:

50

answers:

1

i am trying to play an intro movie (like a splash screen). it used to work fine for sdk 3.0 but now i am doing it for iPad. and its not running movie instead it just show black screen before view appears. here is my code

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"intro" ofType:@"m4v" inDirectory:nil];
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:movieURL];
moviePlayer.fullscreen=YES;
moviePlayer.view.frame = CGRectMake(0, 0,1024,768);
[moviePlayer setShouldAutoplay:YES];
[moviePlayer setControlStyle:MPMovieControlStyleNone];
[moviePlayer setRepeatMode:MPMovieRepeatModeNone];

[moviePlayer prepareToPlay];
[moviePlayer play];

[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(moviePlaybackDidFinish:) 
                                             name:MPMoviePlayerPlaybackDidFinishNotification 
                                           object:moviePlayer]; 
return YES;
}

and here is my moviePlaybackDidFinish

- (void) moviePlaybackDidFinish:(NSNotification*)notification
{

MPMoviePlayerController *theMovie = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
                                                name:MPMoviePlayerPlaybackDidFinishNotification
                                              object:theMovie];
theMovie.initialPlaybackTime = -1;
[theMovie pause]; 

[theMovie stop];
[theMovie release];
[window addSubview:viewController.view];
[window makeKeyAndVisible];


 }

i dont know what i am missing here?
thanks for any help....
UPDATE i just found out that it plays sound but no video....is this obvious?pls help

A: 

@Nnp you must add the view of movie player moviePlayer.view.frame = CGRectMake(0, 0,1024,768); [self.view addSubview:moviePlayer.view];
to your view or even to window .
check this link which may help you.... http://cocoabugs.blogspot.com/2010/08/troubleshoting-iphone.html

jeeva
Thanks Jeeva, i will try out soon, and update it...thanks
Nnp
you can accept answers if it solves ur problem...
jeeva