Class AudioPlayer

Inheritance Relationships

Base Type

Class Documentation

class AudioPlayer : public Cacao::Component

Public Functions

AudioPlayer()

Create a new audio player.

Throws:

BadInitStateException – If the audio system is uninitialized

ASTRA_IGNORE void Play ()

Play or resume the audio.

Throws:
  • BadInitStateException – If the audio system is uninitialized

  • NonexistentValueException – If there is no set sound to play

  • BadBakeStateException – If the set sound is not baked

  • BadStateException – If the audio is already playing

ASTRA_IGNORE void Pause ()

Pause audio playback.

Throws:
  • BadInitStateException – If the audio system is uninitialized

  • BadStateException – If no audio is playing

ASTRA_IGNORE void Stop ()

Stop audio playback.

Throws:
  • BadInitStateException – If the audio system is uninitialized

  • BadStateException – If no audio is playing or paused

ASTRA_IGNORE State GetState () const

Check the current state of the audio player.

Throws:

BadInitStateException – If the audio system is uninitialized

Returns:

Current state

ASTRA_IGNORE void SetLooping (bool val)

Set if the audio should loop.

Parameters:

val – If the audio should loop

Throws:

BadInitStateException – If the audio system is uninitialized

ASTRA_IGNORE void SetGain (float val)

Set the gain value.

Parameters:

val – The new gain value

Throws:
  • BadInitStateException – If the audio system is uninitialized

  • BadValueException – If the provided multiplier is negative

ASTRA_IGNORE void SetPitchMultiplier (float val)

Set the pitch multiplier.

Parameters:

val – The new pitch multiplier

  • 0-1: Deeper

  • 1: Normal

  • > 1: Higher

Throws:
  • BadInitStateException – If the audio system is uninitialized

  • BadValueException – If the provided multiplier is negative or zero

ASTRA_IGNORE void SetPosition (float position)

Set the playback position to the specified position in the sound.

Parameters:

position – The new playback position in seconds

Throws:
  • BadInitStateException – If the audio system is uninitialized

  • BadValueException – If the provided position is negative or past the sound’s end point

ASTRA_IGNORE void SetSound (std::shared_ptr< Sound > sound)

Set the sound to be played (may be null)

Parameters:

sound – The new sound

Throws:

BadInitStateException – If the audio system is uninitialized

ASTRA_IGNORE bool GetLooping () const

Check if the audio is looping.

Throws:

BadInitStateException – If the audio system is uninitialized

Returns:

Whether the audio is looping or not

ASTRA_IGNORE float GetGain () const

Get the current gain value.

Throws:

BadInitStateException – If the audio system is uninitialized

Returns:

The current gain value

ASTRA_IGNORE float GetPitchMultiplier () const

Get the current pitch multiplier.

Throws:

BadInitStateException – If the audio system is uninitialized

Returns:

The current pitch multiplier

ASTRA_IGNORE float GetPosition () const

Get the current playback position.

Throws:

BadInitStateException – If the audio system is uninitialized

Returns:

The current playback position in seconds

inline ASTRA_IGNORE std::shared_ptr< Sound > GetSound () const

Get the current sound being played.

Returns:

The current sound

ASTRASETUP (AudioPlayer) virtual ~AudioPlayer()

Public Members

bool autoplay

Whether the audio player should start playing automatically when it’s enabled.