Game Development Community

Play Intro video on iphone with iTGB

by Mario Altimari · in iTorque 2D · 09/14/2009 (7:16 am) · 7 replies

My game has a intro video after i must load the first scene...

1. How can I play a video on iphone with iTGB?
2. Which is the video format to use?
3. How can I load the first scene when the video play is finished?

thanks a lot :-)

#1
09/14/2009 (10:15 am)
I can answer #2 for now - falling asleep at the keyboard here :)

If you import your video into iTunes (at least on 9), you can right-click it and create an iPod/iPhone version from there. It works best if you already have the right resolution (480x320 or so for full widescreen).
#2
09/14/2009 (11:19 am)
but it is possible play video from itgb?
#3
09/14/2009 (11:42 am)
You will need to hook into the default Apple video API.
#4
09/14/2009 (12:05 pm)
@David can you post me example?
#5
09/14/2009 (12:51 pm)
I do not have one on-hand. I'm not sure if anyone has posted one.
#6
09/14/2009 (10:53 pm)
This needs a little bit of work from people who know the innards of the engine. I've made some attempts with a blank project, and it played the video nicely. But when adding the same as a console function to T2Di, I only hear the sound.

Header required:
#import "MediaPlayer/MediaPlayer.h"

Snippet to play:
MPMoviePlayerController *moviePlayer;

	NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"m4v"];
	if (moviePath == NULL) return;

	NSURL *movieURL = [NSURL fileURLWithPath: moviePath];
	moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
	moviePlayer.scalingMode = MPMovieScalingModeAspectFit; // Adjust to fit screen, preserving aspect ratio
	moviePlayer.movieControlMode = MPMovieControlModeHidden; // Show no controls when tapped
	[moviePlayer play];
	[movieURL release];
	[moviePath release];

Putting this into a TorqueScript function isn't enough, though. The player plays in the background, and you'll want to use the notification system to toggle a flag that tells you whether the movie is still playing.

Nice for an intro sequence to mask loading, but not so nice between levels. Plus the fact that the game's scenegraph is displayed frontmost. I dunno how to hide the engine's display so the movie plays frontmost.
#7
09/15/2009 (6:49 am)
I wouldn't hide the engine display but add another UIView which you fade in as it plays the movie and that fades out at the end again to give back view onto itgb