Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Appline

macrumors newbie
Original poster
Apr 17, 2012
3
0
Hey there everyone, I'm trying to put a splashvideo instead of a boring splashscreen in my project, I've been looking on the entire web without find anything but I feel close to solution.
Code:
@implementation SplashVideo_1AppDelegate

@synthesize window=_window;


MPMoviePlayerController *player;


- (void)dealloc
{
    [_window release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   
    // Override point for customization after application launch.
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Splashvideo" ofType:@"m4v"];
                              
    MPMoviePlayerController *player =[[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:filePath]];
    player.fullscreen=YES;
    [player prepareToPlay];
    player.controlStyle=MPMovieControlStyleNone;
   [[player view] setFrame:_window.bounds];
     [self.window addSubview:[player view]]; 
        [player play];
    
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish) name:MPMoviePlayerPlaybackDidFinishNotification object:player];
    

   
           
    
    return YES;

}

-(void) moviePlayBackDidFinish {

    [player.view removeFromSuperview];
    [player release ];
    [_window makeKeyAndVisible];
    
    
}
with this code in the app delegate i can hear the sound of my video but i can't see it even if i said to the program to show me the window when the movie is over.

could anyone help me?

P.S. sorry for my bad english
 
ok now i'm closer!!
Code:
@implementation SplashVideo_1AppDelegate

@synthesize window=_window;


MPMoviePlayerController *player;


- (void)dealloc
{
    [_window release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   
    // Override point for customization after application launch.
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Splashvideo" ofType:@"m4v"];
                              
    MPMoviePlayerViewController *player =[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:filePath]];
   /* player.fullscreen=YES;
    [player prepareToPlay];
    player.controlStyle=MPMovieControlStyleNone;*/
   [[player view] setFrame:_window.bounds];
     [self.window addSubview:[player view]]; 
    self.window.rootViewController.view=player.moviePlayer.view;
    
        player.moviePlayer.shouldAutoplay=YES;
    
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish) name:MPMoviePlayerPlaybackDidFinishNotification object:player];
    

   
           
    
    return YES;

}

-(void) moviePlayBackDidFinish {

    [player.view removeFromSuperview];
    [player release ];
    [_window makeKeyAndVisible];
    
    
}
Now the first thing that see it's the video the only thing is that i'm stuck in the video and i can't get out this must be some moviePlayBackDidFinish problem but MPMoviePlayerViewController can't handle the playback finish statement :(
 
I'm not a fan of heavy lifting in the app delegate. I'd rather create an IBAction in the main viewcontroller that is called from the app delegate.

Code:
//app delegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
    [viewController startmovie];

    [self.window addSubview:viewController.view];
    [self.window makeKeyAndVisible];

    return YES;
}

//myviewcontroller.m

-(IBAction)startmovie{
//play movie
}

Nick
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.