Game Development Reference
In-Depth Information
Before we begin, there are two things to consider when using video clips in our
games. The first is that while it is possible to specify where on the screen the video
clip will appear, it will always be drawn on top of all other graphics. The second
issue is that due to hardware limitations in many mobile devices, the s3eVideo API
cannot be used at the same time as the s3eAudio and s3eSound APIs. In the case of
s3eAudio, any currently playing track will be stopped (this also applies the other
way around—starting an audio track will stop a currently playing video clip). The
s3eSound API will continue processing its events while a video clip is playing, but
its sound output will be silenced until the video clip is finished. For most games
we would probably decide it is best to explicitly stop all s3eSound playback before
starting a video clip, particularly if we are doing anything advanced like joining
sound samples together using the callback system.
Starting video playback
The s3eVideo API works in a similar manner to the s3eAudio API. To start playing
a video clip we use the s3eVideoPlay function, specifying the filename of the video
clip, the number of times we want it to loop, a screen position, and the size that we
want to display it at, as follows:
s3eVideoPlay(lFileName, lRepeatCount, lX, lY, lWidth, lHeight);
The video clip will automatically resize to fit the rectangle, but no attempt is made to
keep the correct aspect ratio.
Where possible it is usually best to try to make your video clips the same resolution
as the rectangular area you want to display them in. This will avoid any unnecessary
stretching of the image (which can look quite ugly!) and may lead to slightly better
performance, though on most modern devices the resize will be happening in
hardware and there will be no appreciable difference.
The actual size of the video file itself is also worth bearing in mind, since we often
want to minimize the size of the final install package. Ultimately, we need to use a bit
of trial and error until we get a result that ticks all the boxes for acceptable quality,
performance, and file size.
Determining video codec support
The s3eVideo API makes use of the device's built-in video decoding, so not all
video formats will be playable on all devices. To determine whether support for a
particular codec is available, there is a function called s3eVideoIsCodecSupported
that takes a value from the s3eVideoCodec enum. Take a look at the s3eVideo.h ile
or the Marmalade documentation for a complete list of possible values.
 
Search WWH ::




Custom Search