Loading...
Searching...
No Matches
Public Member Functions | List of all members
BFileGameSound Class Reference

Playback audio from a sound file on disk. More...

Inherits BStreamingGameSound.

Public Member Functions

 BFileGameSound (BDataIO *data, bool looping=true, BGameSoundDevice *device=NULL)
 Creates and initializes a BFileGameSound object from a BDataIO allowing you to play the specified sound data.
 
 BFileGameSound (const char *file, bool looping=true, BGameSoundDevice *device=NULL)
 Creates and initializes a BFileGameSound object from a file path allowing you to play the specified sound file.
 
 BFileGameSound (const entry_ref *file, bool looping=true, BGameSoundDevice *device=NULL)
 Creates and initializes a BFileGameSound object from an entry_ref allowing you to play the specified sound file.
 
virtual ~BFileGameSound ()
 Destroys the BFileGameSound object.
 
virtual BGameSound * Clone () const
 Not implemented, always returns NULL.
 
virtual void FillBuffer (void *buffer, size_t byteCount)
 Fill a buffer with sound data.
 
int32 IsPaused ()
 Returns the current playback status.
 
status_t Preload ()
 Preload the sound file into memory so that playback won't be delayed.
 
virtual status_t SetPaused (bool isPaused, bigtime_t rampTime)
 Pauses playback if isPaused is true or resumes play if isPaused is false.
 
virtual status_t StartPlaying ()
 Plays the sound file.
 
virtual status_t StopPlaying ()
 Stops playback of the sound file.
 

Detailed Description

Playback audio from a sound file on disk.

Since
BeOS R5

Constructor & Destructor Documentation

◆ BFileGameSound() [1/3]

BFileGameSound::BFileGameSound ( const entry_ref file,
bool  looping = true,
BGameSoundDevice *  device = NULL 
)

Creates and initializes a BFileGameSound object from an entry_ref allowing you to play the specified sound file.

If looping is true, the sound automatically replays from the beginning once the end is reached. This is useful for playing background music in a loop.

You can specify the sound device to use by setting the device parameter. Setting device to NULL uses the default sound device.

Parameters
fileThe entry ref pointing to the sound file on disk.
loopingWhether or not to repeat the sound in a loop.
deviceThe sound device to use to play the sound, use NULL for default.
Since
BeOS R5

◆ BFileGameSound() [2/3]

BFileGameSound::BFileGameSound ( const char *  file,
bool  looping = true,
BGameSoundDevice *  device = NULL 
)

Creates and initializes a BFileGameSound object from a file path allowing you to play the specified sound file.

If looping is true, the sound automatically replays from the beginning once the end is reached. This is useful for playing background music in a loop.

You can specify the sound device to use by setting the device parameter. Setting device to NULL uses the default sound device.

Parameters
fileThe path of the sound file on disk.
loopingWhether or not to repeat the sound in a loop.
deviceThe sound device to use to play the sound, use NULL for default.
Since
BeOS R5

◆ BFileGameSound() [3/3]

BFileGameSound::BFileGameSound ( BDataIO source,
bool  looping = true,
BGameSoundDevice *  device = NULL 
)

Creates and initializes a BFileGameSound object from a BDataIO allowing you to play the specified sound data.

This allows using BFileGameSound with BFile as well as non-file based storage (BMemoryIO, etc).

If looping is true, the sound automatically replays from the beginning once the end is reached. This is useful for playing background music in a loop.

You can specify the sound device to use by setting the device parameter. Setting device to NULL uses the default sound device.

Parameters
sourceThe place to get the data from.
loopingWhether or not to repeat the sound in a loop.
deviceThe sound device to use to play the sound, use NULL for default.
Since
Haiku R1

◆ ~BFileGameSound()

BFileGameSound::~BFileGameSound ( )
virtual

Destroys the BFileGameSound object.

Since
BeOS R5

Member Function Documentation

◆ Clone()

BGameSound * BFileGameSound::Clone ( ) const
virtual

Not implemented, always returns NULL.

Since
BeOS R5

◆ FillBuffer()

void BFileGameSound::FillBuffer ( void *  inBuffer,
size_t  inByteCount 
)
virtual

Fill a buffer with sound data.

Parameters
inBufferThe buffer to fill.
inByteCountThe number of bytes to fill buffer with.
Since
BeOS R5

◆ IsPaused()

int32 BFileGameSound::IsPaused ( )

Returns the current playback status.

Returns
An integer indicating the current playback status.
Return values
B_NOT_PAUSEDSound is playing.
B_PAUSE_IN_PROGRESSThe sound is transitioning to or from a paused state.
B_PAUSEDSound is paused.
Since
BeOS R5

◆ Preload()

status_t BFileGameSound::Preload ( )

Preload the sound file into memory so that playback won't be delayed.

Returns
A status code, B_OK on success or an error code if we were unable to communicate with the sound port.
Since
BeOS R5

◆ SetPaused()

status_t BFileGameSound::SetPaused ( bool  isPaused,
bigtime_t  rampTime 
)
virtual

Pauses playback if isPaused is true or resumes play if isPaused is false.

Parameters
isPausedtrue to pause playback, false to resume playback.
rampTimeDetermines how long the change in playback state should take to complete in microseconds. Set to 0 for an instantaneous change.
Returns
A status code.
Return values
B_OKThe playback state was updated.
EALREADYAlready in the requested playback state.
Since
BeOS R5

◆ StartPlaying()

status_t BFileGameSound::StartPlaying ( )
virtual

Plays the sound file.

Returns
A status code, B_OK on success or an error code on error.
Since
BeOS R5

◆ StopPlaying()

status_t BFileGameSound::StopPlaying ( )
virtual

Stops playback of the sound file.

Returns
A status code, B_OK on success or an error code on error.
Since
BeOS R5