Table of Contents

Class AudioStreamPlayer

Namespace
Godot
Assembly
GodotSharp.dll

Plays an audio stream non-positionally.

To play audio positionally, use AudioStreamPlayer2D or AudioStreamPlayer3D instead of AudioStreamPlayer.

public class AudioStreamPlayer : Node, IDisposable
Inheritance
AudioStreamPlayer
Implements
Inherited Members

Constructors

AudioStreamPlayer()

public AudioStreamPlayer()

Properties

Autoplay

If true, audio plays when added to scene tree.

public bool Autoplay { get; set; }

Property Value

bool

Bus

Bus on which this audio is playing.

Note: When setting this property, keep in mind that no validation is performed to see if the given name matches an existing bus. This is because audio bus layouts might be loaded after this property is set. If this given name can't be resolved at runtime, it will fall back to "Master".

public StringName Bus { get; set; }

Property Value

StringName

MaxPolyphony

The maximum number of sounds this node can play at the same time. Playing additional sounds after this value is reached will cut off the oldest sounds.

public int MaxPolyphony { get; set; }

Property Value

int

MixTarget

If the audio configuration has more than two speakers, this sets the target channels. See AudioStreamPlayer.MixTargetEnum constants.

public AudioStreamPlayer.MixTargetEnum MixTarget { get; set; }

Property Value

AudioStreamPlayer.MixTargetEnum

PitchScale

The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.

public float PitchScale { get; set; }

Property Value

float

Playing

If true, audio is playing.

public bool Playing { get; set; }

Property Value

bool

Stream

The AudioStream object to be played.

public AudioStream Stream { get; set; }

Property Value

AudioStream

StreamPaused

If true, the playback is paused. You can resume it by setting StreamPaused to false.

public bool StreamPaused { get; set; }

Property Value

bool

VolumeDb

Volume of sound, in dB.

public float VolumeDb { get; set; }

Property Value

float

Methods

GetPlaybackPosition()

Returns the position in the AudioStream in seconds.

public float GetPlaybackPosition()

Returns

float

GetStreamPlayback()

Returns the AudioStreamPlayback object associated with this AudioStreamPlayer.

public AudioStreamPlayback GetStreamPlayback()

Returns

AudioStreamPlayback

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

HasStreamPlayback()

Returns whether the AudioStreamPlayer can return the AudioStreamPlayback object or not.

public bool HasStreamPlayback()

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

Play(float)

Plays the audio from the given fromPosition, in seconds.

public void Play(float fromPosition = 0)

Parameters

fromPosition float

Seek(float)

Sets the position from which audio will be played, in seconds.

public void Seek(float toPosition)

Parameters

toPosition float

Stop()

Stops the audio.

public void Stop()

Events

Finished

Emitted when the audio stops playing.

public event Action Finished

Event Type

Action