The Game Kit Table of Contents | The Game Kit Index |
Derived from: BStreamingGameSound
Declared in: be/game/FileGameSound.h
Library: libgame.so
Allocation: Constructor only
If you want to play back audio from a disk file, such as background music, or low-priority sound effects, BFileGameSound is for you. Keep in mind that if the sound needs to play at precise moments, or latency is an issue, that BFileGameSound may not be appropriate for your needs.
Using BFileGameSound is easy, and it supports automatically looping sounds. The following code snippet starts up the theme music for the hot new game "Mystery Warriors From the Doomed Planet Z":
BFileGameSound themeSong("music/theme.aif", true); themeSong.StartPlaying();
This starts up a looped sound from the file music/theme.aif. If you want the theme to only play through once, just specify false instead of true for the looping argument to the BFileGameSound constructor.
You can pause the BFileGameSound by calling SetPaused():
themeSong.SetPaused(true, 0);
This pauses the sound, effective immediately. The pause can optionally be ramped, so that the sound slows down or speeds up to reach the new setting. For example:
themeSong.SetPaused(true, 2);
This causes the sound to slow down over the course of two seconds, until it's stopped.
The inverse is also possible:
themeSong.SetPaused(false, 0);
This resumes playback immediately. You can ramp the resume by specifying a non-zero value for the ramp time.
BFileGameSound uses the BMediaFile class to access the sound file. If BMediaFile can't identify the sound, the file is assumed to contain raw 44.1kHz, 16-bit stereo.
|
Prepares the object to play the specified sound file, which can be specified either by entry_ref or pathname in the inFile argument.
If the looping flag is true (which it is by default), the sound automatically loops back to the beginning and replays when the end of the sound is reached. This is useful for easily playing background music (for example).
In both cases, device specifies the sound device that should be used for playing the sound; NULL uses the default sound player.
...in lovely HTML... for BeOS Release 5. Copyright © 2000 Be, Inc. All rights reserved.. |