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!

Community
  • 1
  • 1
  • I know it's silly, but there is no way to start such a stuff. But some workaround is possible [here](http://stackoverflow.com/questions/7051208/emulating-splash-video-in-ios-application/7051256#7051256) – Watsche Jul 16 '14 at 06:57

1 Answers1

0

So after the splash screen, Your first view controller can have this:

-(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];

}

More info: https://developer.apple.com/library/ios/documentation/audiovideo/conceptual/multimediapg/UsingVideo/UsingVideo.html

In myMovieFinishedCallback, you can then show the menu of the game.

I hope I helped :)

Ricardo Anjos
  • 1,417
  • 18
  • 22
  • Ricardo, I am developing for OSX so there is no MPMediaPlayerController. I am going to have to work with AVPlayer. – snoopyCache Jul 17 '14 at 00:04