相关疑难解决方法(0)

在iOS应用程序中模拟启动视频

好的,在iOS中模拟启动视频的选项很少.我们所能做的就是等到应用程序完全加载,然后创建Media Player并在其中加载视频.

我用以下代码实现了它:

-(void) moviePlayBackDidFinish:(NSNotification*)notification
{
    NSLog(@"Intro video stopped");
    [mMoviePlayer release];
}

- (void)applicationDidFinishLaunching:(UIApplication *)application {
    NSURL* mMovieURL;
    NSBundle *bundle = [NSBundle mainBundle];
    if(bundle != nil)
    {
        NSString *moviePath = [bundle pathForResource:@"intro" ofType:@"mp4"];
        if (moviePath)
        {
            mMovieURL = [NSURL fileURLWithPath:moviePath];
            [mMovieURL retain];
        }
    }

    mMoviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:mMovieURL];
    [mMovieURL release];

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(moviePlayBackDidFinish:) 
                                                 name:MPMoviePlayerPlaybackDidFinishNotification 
                                               object:mMoviePlayer];

    mMoviePlayer.controlStyle = MPMovieControlStyleNone;
    [mMoviePlayer.backgroundView addSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Splash/background.png"]] autorelease]];
    mMoviePlayer.scalingMode = MPMovieScalingModeFill;

    [window addSubview:mMoviePlayer.view];
    [mMoviePlayer setFullscreen:YES animated:NO];

    [window makeKeyAndVisible];
    [mMoviePlayer play];

<... other …
Run Code Online (Sandbox Code Playgroud)

iphone splash-screen mpmovieplayercontroller ipad

11
推荐指数
2
解决办法
1万
查看次数