Table of Contents

Class AudioStreamPlayback

Meta class for playing back audio.

Inheritance
AudioStreamPlayback
Derived

Remarks

Can play, loop, pause a scroll through audio. See AudioStream and AudioStreamOggVorbis for usage.

See Also

Methods

_get_loop_count

Qualifiers: virtualconst

Overridable method. Should return how many times this audio stream has looped. Most built-in playbacks always return 0.

int _get_loop_count

_get_parameter(StringName)

Qualifiers: virtualconst

Return the current value of a playback parameter by name (see _get_parameter_list).

Variant _get_parameter(StringName name)

Parameters

name StringName

_get_playback_position

Qualifiers: virtualconst

Overridable method. Should return the current progress along the audio stream, in seconds.

float _get_playback_position

_is_playing

Qualifiers: virtualconst

Overridable method. Should return true if this playback is active and playing its audio stream.

bool _is_playing

_mix(AudioFrame*, float, int)

Qualifiers: virtual

Override this method to customize how the audio stream is mixed. This method is called even if the playback is not active.

Note: It is not useful to override this method in GDScript or C#. Only GDExtension can take advantage of it.

int _mix(AudioFrame* buffer, float rate_scale, int frames)

Parameters

buffer AudioFrame*
rate_scale float
frames int

_seek(float)

Qualifiers: virtual

Override this method to customize what happens when seeking this audio stream at the given position, such as by calling AudioStreamPlayer.seek.

void _seek(float position)

Parameters

position float

_set_parameter(StringName, Variant)

Qualifiers: virtual

Set the current value of a playback parameter by name (see _get_parameter_list).

void _set_parameter(StringName name, Variant value)

Parameters

name StringName
value Variant

_start(float)

Qualifiers: virtual

Override this method to customize what happens when the playback starts at the given position, such as by calling AudioStreamPlayer.play.

void _start(float from_pos)

Parameters

from_pos float

_stop

Qualifiers: virtual

Override this method to customize what happens when the playback is stopped, such as by calling stop.

void _stop

_tag_used_streams

Qualifiers: virtual

Overridable method. Called whenever the audio stream is mixed if the playback is active and AudioServer.set_enable_tagging_used_audio_streams has been set to true. Editor plugins may use this method to "tag" the current position along the audio stream and display it in a preview.

void _tag_used_streams

get_loop_count

Qualifiers: const

Returns the number of times the stream has looped.

int get_loop_count

get_playback_position

Qualifiers: const

Returns the current position in the stream, in seconds.

float get_playback_position

get_sample_playback

Qualifiers: const

Returns the AudioSamplePlayback associated with this AudioStreamPlayback for playing back the audio sample of this stream.

AudioSamplePlayback get_sample_playback

is_playing

Qualifiers: const

Returns true if the stream is playing.

bool is_playing

mix_audio(float, int)

Mixes up to frames of audio from the stream from the current position, at a rate of rate_scale, advancing the stream.

Returns a PackedVector2Array where each element holds the left and right channel volume levels of each frame.

Note: Can return fewer frames than requested, make sure to use the size of the return value.

PackedVector2Array mix_audio(float rate_scale, int frames)

Parameters

rate_scale float
frames int

seek(float)

Seeks the stream at the given time, in seconds.

void seek(float time)

Parameters

time float

set_sample_playback(AudioSamplePlayback)

Associates AudioSamplePlayback to this AudioStreamPlayback for playing back the audio sample of this stream.

void set_sample_playback(AudioSamplePlayback playback_sample)

Parameters

playback_sample AudioSamplePlayback

start(float)

Starts the stream from the given from_pos, in seconds.

void start(float from_pos)

Parameters

from_pos float

stop

Stops the stream.

void stop