November 2011
Beginner
196 pages
5h 3m
English
Playing videos during games is unusual, but they have a very important purpose in introducing games or prior to each level. Fortunately, videos are handled pretty much identically to music and other audio. In fact, to test a video, you can replace the .mid file with a .3gp file. Then, when the surface is created, the video will play.
Doing a quick Internet search for 3GP videos offers a plethora of options. If you have music videos in the .mp4 format, you can also add those to your raw resource folder. Listing 4-5 contains the code used for playing one of these files.
Listing 4-5. Playing a Video
@Override
public void surfaceCreated(SurfaceHolder holder) {
mGameLogic.setGameState(mGameLogic.RUNNING); mGameLogic.start(); ...Read now
Unlock full access