User Guide
54 Working with Sound, Video, and Images
About synchronizing device sounds with animation
Device sounds in Flash Lite are always treated as event sounds. This means that you can’t
synchronize device sounds with animation in the timeline in the same manner that you can
with native Flash sounds. However, you can use device sounds to approximate true
synchronized sound by setting the Flash Lite player’s
_forceframerate property to true.
When this property is set to
true, Flash Lite drops frames from animation to maintain the
SWF file’s specified frame rate. As long as the device sound data is authored for the correct
duration, and as long as the device plays back sound data at the expected rate, animation and
sound will be close to being synchronized.
For example, suppose you have a device sound that’s 5 seconds long. During playback, you’d
like this sound to play in synch with animation in the timeline. Also assume that your
application’s frame rate is set to 15 FPS. When you start the sound—either by attaching it to
a frame in the timeline or calling
Sound.start()—you simultaneously set
_forceframerate = "true". Subsequently, for each second of device audio playback, Flash
Lite ensures that the playback head has advanced 15 frames in the timeline. If, for some
reason, the player cannot render each frame in the animation during this time, it drops frames
to maintain the specified frame rate.
For more information about the
_forceframerate property, see _forceframerate property
in Flash Lite 2.x ActionScript Language Reference.
Determining supported device sound formats
The System.capabilities.audioMIMETypes property contains an array of audio MIME
types that the device supports. You can use this information to determine what types of device
audio your application can play. The array’s indexes are the same as the supported MIME
types, so you can easily check whether a device supports a specific type of audio.
For example, the following code first checks whether the device supports playback of MIDI
audio before loading an external MIDI file:
if (System.capabilities.audioMIMETypes["audio/midi"]) {
my_sound.loadSound("soundtrack.mid");
}