nCine::AudioStreamPlayer class

Plays back an AudioStream decoded on the fly.

Suitable for long sounds such as music. Owns the AudioStream it plays and forwards most queries to it.

Base classes

class IAudioPlayer
Interface for an audio player.

Public static functions

static auto sType() -> ObjectType
Returns the static object type of this class.

Constructors, destructors, conversion operators

AudioStreamPlayer()
AudioStreamPlayer(StringView filename) explicit
Creates a player and loads the stream from the specified file.
~AudioStreamPlayer() override
AudioStreamPlayer(const AudioStreamPlayer&) deleted
AudioStreamPlayer(AudioStreamPlayer&&) defaulted

Public functions

auto operator=(const AudioStreamPlayer&) -> AudioStreamPlayer& deleted
auto operator=(AudioStreamPlayer&&) -> AudioStreamPlayer& defaulted
auto loadFromFile(const char* filename) -> bool
Loads the stream from the specified file.
auto bufferId() const -> std::uint32_t override
Returns the OpenAL id of the currently playing buffer.
auto bytesPerSample() const -> std::int32_t override
Returns the number of bytes per sample.
auto numChannels() const -> std::int32_t override
Returns the number of audio channels of the currently playing buffer.
auto frequency() const -> std::int32_t override
Returns the sample frequency of the currently playing buffer.
auto numSamples() const -> std::int32_t override
Returns the total number of samples.
auto duration() const -> float override
Returns the duration in seconds.
auto bufferSize() const -> std::int32_t override
Returns the size of the currently playing buffer in bytes.
auto numStreamSamples() const -> std::int32_t
Returns the number of samples held by a single streaming buffer.
auto streamBufferSize() const -> std::int32_t
Returns the size of a single streaming buffer in bytes.
void play() override
Starts or resumes playback.
void pause() override
Pauses playback at the current position.
void stop() override
Stops playback and rewinds to the beginning.
void setLooping(bool value) override
Sets whether the player should loop.
void updateState() override
Updates the player state once the source has finished playing.

Function documentation

void nCine::AudioStreamPlayer::updateState() override

Updates the player state once the source has finished playing.

Called every frame by IAudioDevice. In stream players it is also responsible for queueing and unqueueing buffers.