Game Development Community

iPhone Movie Playback - Here it is.

by Sven Bergström · in iTorque 2D · 10/23/2009 (9:18 pm) · 48 replies

One thing that was always a cool idea was playing cinematics and, intro movies in an iPhone game. Up until now there have been people planning to add it but i had already started so here it is.

Notes

The code is asynchronous - Meaning that the game/other stuff still runs in the background. This is great for loading stuff in the background while the movie is playing :) One thing i will add is that a movieID will be returned, and call the console function for movieDidFinishPlayback(%ID), so that you can time things better.

Todo
make it use ~/ paths.
maybe add datablocks for videos


"Installation"


Step 1 : , you need to add the two files to your project tree.

img190.imageshack.us/img190/1749/vid07.png

img18.imageshack.us/img18/4365/vid08.png


Step 2 : , you need to add the MediaPlayer Framework.

On the target -> Right click -> Get Info
Select the general tab
Make sure you are adding from the iPhoneOS SDK

img14.imageshack.us/img14/3808/vid09.png


Step 3 : , Build and go.

Usage


NO EXTENSION is passed in, m4v is the only one atm, it looks in the bundle based on the file name, starting at / (which is "Resources" in XCode.

Someone asked about it being modal and not dismissable, if you set the controlsMode to hidden or volume only there is no way to dismiss the movie (meaning you can force them to watch it). The other thing i will add is the callback for handling when they are attempting to dismiss the video from modal mode as well - So that you can perhaps show another loading screen if your background loading is not complete.

There is only one function needed. The scalemode and controlMode are from the OS :

For scaling - None, Aspect Fit, Aspect Fill, Fill
For controls - Default controls, Volume Only, Hidden

Code side :
//If you going to code it, just look at the parameters in the code :)
#include "platformiPhone/iPhoneMoviePlayback.h"

playMovie(...);

Script Side

//You will have to use numbers or constants here for now
playiPhoneMovie( %filename, %scaleMode, %controlMode );

Creating a movie for the game


Quite simple , just use iTunes.

Step 1 : ,

Add a video file by opening it in iTunes

img190.imageshack.us/img190/709/vid00.png
Step 2 : ,

Change the view to be this view, so you can see the "Movies" tab on the left, and the items in a list format.

img194.imageshack.us/img194/7697/vid01.png
Step 3 : ,

Right click the video and convert it to iPhone/iPod version


img196.imageshack.us/img196/6153/vid03.png
img196.imageshack.us/img196/3793/vid04.png

Always check the settings!

img8.imageshack.us/img8/1349/vid05.png
Step 4 : ,

Rinse and repeat :)

img18.imageshack.us/img18/528/vid06.png

Downloads


Download
Page«First 1 2 3 Next»
#41
02/24/2010 (12:12 pm)
In iMovie, make sure you are exporting for mobile device. I don't have the program with me right now, but I remember it is not under the file menu... I think it's something like "export for device"...
#42
02/24/2010 (12:15 pm)
now got an "EXC_BAD_ACCESS"...:

u32 instruction = code[ip++]

no idea what´s wrong.

Still being a newbie on several stuff :(
#43
02/24/2010 (12:19 pm)
thanks guys, I did the conversion, but now the problem is the Exec Bad Access :(
#44
02/25/2010 (2:22 pm)
Well, I was unable to run the video using 1.3.1 no matter if I read or not the documentation... it seems that I´m stupid enough to be unable to understand the new datablocks stuff. I´ve tried reading carefully but not, I still having an empty level.

My solution is nothing elegant: I did my level using 1.2 beta and then I´ve imported the game folder to my 1.3.1 game folder and that did the trick. I can play now videos.

But now, I´ve searched and there is no, or I can´t figure where it is this information: How do you pause a video through code (if possible) and how do you skill and how do you call when the video was finished. Is there something like onVideoFinished() or something?

Thanks in advance

Isaac
#45
03/17/2010 (1:02 pm)
The solution works great, but as issac im trying to find how to find out when the video finish. If there a event like onFinishVideo() would be great. has someone did this?
#46
03/18/2010 (4:34 pm)
@Sven,

Hi, I think you´re the guy I need to ask again: is there a way to do something once the video has been played or when the user decides to quit it? Is there a way to force the player to watch the video?

I know you may be busy working on other stuff, but this is very important for me so I can start working with a project. Otherwise I must stop working since I´m in the newbies side.

Thanks in advance man!
#47
07/27/2010 (9:22 pm)
after the updato to SDK 4.0 the Movie Player don't work :-(
#48
09/11/2010 (10:52 am)
http://www.torquepowered.com/community/forums/viewthread/120465
working in SDK 4.0!
Page«First 1 2 3 Next»