blip  0.1
AudioPlayer Class Reference

An audio playback object. More...

#include <AudioPlayer.hpp>

Public Member Functions

 ~AudioPlayer ()
 Destructor. More...
 
void start ()
 Start audio playback. More...
 
void stop ()
 Stop audio playback. More...
 
void pause ()
 Pause audio playback. More...
 
void setVolume (int volumeMB)
 Set the player volume. More...
 
bool enqueueData (byte_t *data, size_t length)
 Enqueue a buffer of audio data for playback. More...
 
void clear ()
 Release all enequeued audio data buffers. More...
 
timespan_ms_t getDuration ()
 Get the total duration of the currently enqueued audio data. More...
 
timespan_ms_t getPosition ()
 Get the position within the currently enqueued audio data. More...
 
const AudioFormatgetAudioFormat () const
 Get the AudioFormat for this player. More...
 
bool isPlaying () const
 Test if this player is currently playing audio. More...
 

Detailed Description

An audio playback object.

Instances of this class are created using the AudioEngine. Each AudioPlayer represents an independent audio playback stream; all such streams are mixed to the audio device by the AudioEngine.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ ~AudioPlayer()

Destructor.

Member Function Documentation

◆ clear()

void clear ( )

Release all enequeued audio data buffers.

Exceptions
AudioExceptionIf an error occurs.

◆ enqueueData()

bool enqueueData ( byte_t *  data,
size_t  length 
)

Enqueue a buffer of audio data for playback.

Parameters
dataThe buffer of audio data.
lengthThe length of the buffer, in bytes.
Exceptions
AudioExceptionIf an error occurs.

◆ getAudioFormat()

const AudioFormat& getAudioFormat ( ) const
inline

Get the AudioFormat for this player.

◆ getDuration()

timespan_ms_t getDuration ( )

Get the total duration of the currently enqueued audio data.

Returns
The duration, in milliseconds.
Exceptions
AudioExceptionIf an error occurs.

◆ getPosition()

timespan_ms_t getPosition ( )

Get the position within the currently enqueued audio data.

Returns
The current position, in milliseconds. This position is relative to the beginning of the first buffer that was enqueued after the most recent clear() call.
Exceptions
AudioExceptionIf an error occurs.

◆ isPlaying()

bool isPlaying ( ) const
inline

Test if this player is currently playing audio.

◆ pause()

void pause ( )

Pause audio playback.

A subsequent call to start() will resume playback at the point where it was paused.

Exceptions
AudioExceptionIf an error occurs.

◆ setVolume()

void setVolume ( int  volumeMB)

Set the player volume.

Parameters
volumeMBThe new volume, in millibars.
Exceptions
AudioExceptionIf an error occurs.

◆ start()

void start ( )

Start audio playback.

Exceptions
AudioExceptionIf an error occurs.

◆ stop()

void stop ( )

Stop audio playback.

A subsequent call to start() will resume playback at the beginning.

Exceptions
AudioExceptionIf an error occurs.

The documentation for this class was generated from the following files: