0

I would like to play an intro video before my game starts on OSX. What is the easiest way to setup an AVPlayer and play the video? I would like the video to play completely before the game can proceed any further.

I have gone through the AVPlayer documentation on the mac developer library but ran into the following problem on my OSX app: AVPlayer does not show video

Please help!

4

1 回答 1

0

所以在启动画面之后,你的第一个视图控制器可以有这个:

-(void) playMovieAtURL: (NSURL*) theURL {





 MPMoviePlayerController* theMovie =

                [[MPMoviePlayerController alloc] initWithContentURL: theURL];



    theMovie.scalingMode = MPMovieScalingModeAspectFill;

    theMovie.movieControlMode = MPMovieControlModeHidden;



    // Register for the playback finished notification

    [[NSNotificationCenter defaultCenter]

                    addObserver: self

                       selector: @selector(myMovieFinishedCallback:)

                           name: MPMoviePlayerPlaybackDidFinishNotification

                         object: theMovie];



    // Movie playback is asynchronous, so this method returns immediately.

    [theMovie play];

}



// When the movie is done, release the controller.

-(void) myMovieFinishedCallback: (NSNotification*) aNotification

{

    MPMoviePlayerController* theMovie = [aNotification object];



    [[NSNotificationCenter defaultCenter]

                    removeObserver: self

                              name: MPMoviePlayerPlaybackDidFinishNotification

                            object: theMovie];



    // Release the movie instance created in playMovieAtURL:

    [theMovie release];

}

更多信息:https ://developer.apple.com/library/ios/documentation/audiovideo/conceptual/multimediapg/UsingVideo/UsingVideo.html

在 myMovieFinishedCallback 中,您可以显示游戏的菜单。

我希望我有所帮助:)

于 2014-07-16T07:41:30.233 回答