AudioStreamPlayer

Hereda: Node < Object

Un nodo para la reproducción de audio.

Descripción

The AudioStreamPlayer node plays an audio stream non-positionally. It is ideal for user interfaces, menus, or background music.

To use this node, stream needs to be set to a valid AudioStream resource. Playing more than one sound at the same time is also supported, see max_polyphony.

If you need to play audio at a specific position, use AudioStreamPlayer2D or AudioStreamPlayer3D instead.

Tutoriales

Propiedades

bool

autoplay

false

StringName

bus

&"Master"

int

max_polyphony

1

MixTarget

mix_target

0

float

pitch_scale

1.0

PlaybackType

playback_type

0

bool

playing

false

AudioStream

stream

bool

stream_paused

false

float

volume_db

0.0

float

volume_linear

Métodos

float

get_playback_position()

AudioStreamPlayback

get_stream_playback()

bool

has_stream_playback()

void

play(from_position: float = 0.0)

void

seek(to_position: float)

void

stop()


Señales

finished() 🔗

Emitida cuando un sonido termina de reproducirse sin interrupciones. Esta señal no se emite al llamar a stop(), o al salir del árbol mientras los sonidos se están reproduciendo.


Enumeraciones

enum MixTarget: 🔗

MixTarget MIX_TARGET_STEREO = 0

El audio se reproducirá solo en el primer canal. Este es el comportamiento predeterminado.

MixTarget MIX_TARGET_SURROUND = 1

El audio se reproducirá en todos los canales de sonido envolvente.

MixTarget MIX_TARGET_CENTER = 2

El audio se reproducirá en el segundo canal, que suele ser el del centro.


Descripciones de Propiedades

bool autoplay = false 🔗

  • void set_autoplay(value: bool)

  • bool is_autoplay_enabled()

If true, this node calls play() when entering the tree.


StringName bus = &"Master" 🔗

The target bus name. All sounds from this node will be playing on this bus.

Note: At runtime, if no bus with the given name exists, all sounds will fall back on "Master". See also AudioServer.get_bus_name().


int max_polyphony = 1 🔗

  • void set_max_polyphony(value: int)

  • int get_max_polyphony()

El número máximo de sonidos que este nodo puede reproducir simultáneamente. Al llamar a play() después de alcanzar este valor, se eliminarán los sonidos más antiguos.


MixTarget mix_target = 0 🔗

The mix target channels. Has no effect when two speakers or less are detected (see SpeakerMode).


float pitch_scale = 1.0 🔗

  • void set_pitch_scale(value: float)

  • float get_pitch_scale()

The audio's pitch and tempo, as a multiplier of the stream's sample rate. A value of 2.0 doubles the audio's pitch, while a value of 0.5 halves the pitch.


PlaybackType playback_type = 0 🔗

Experimental: Esta propiedad podría ser modificada o eliminada en versiones futuras.

The playback type of the stream player. If set other than to the default value, it will force that playback type.


bool playing = false 🔗

  • void set_playing(value: bool)

  • bool is_playing()

If true, this node is playing sounds. Setting this property has the same effect as play() and stop().


AudioStream stream 🔗

El recurso AudioStream que se reproducirá. Al configurar esta propiedad, se detendrán todos los sonidos que se estén reproduciendo. Si se deja vacía, AudioStreamPlayer no funcionará.


bool stream_paused = false 🔗

  • void set_stream_paused(value: bool)

  • bool get_stream_paused()

If true, the sounds are paused. Setting stream_paused to false resumes all sounds.

Note: This property is automatically changed when exiting or entering the tree, or this node is paused (see Node.process_mode).


float volume_db = 0.0 🔗

  • void set_volume_db(value: float)

  • float get_volume_db()

Volume of sound, in decibels. This is an offset of the stream's volume.

Note: To convert between decibel and linear energy (like most volume sliders do), use volume_linear, or @GlobalScope.db_to_linear() and @GlobalScope.linear_to_db().


float volume_linear 🔗

  • void set_volume_linear(value: float)

  • float get_volume_linear()

Volumen del sonido, como un valor lineal.

Nota: Este miembro modifica volume_db por conveniencia. El valor devuelto es equivalente al resultado de @GlobalScope.db_to_linear() sobre volume_db. Establecer este miembro es equivalente a establecer volume_db al resultado de @GlobalScope.linear_to_db() sobre un valor.


Descripciones de Métodos

float get_playback_position() 🔗

Returns the position in the AudioStream of the latest sound, in seconds. Returns 0.0 if no sounds are playing.

Note: The position is not always accurate, as the AudioServer does not mix audio every processed frame. To get more accurate results, add AudioServer.get_time_since_last_mix() to the returned position.

Note: This method always returns 0.0 if the stream is an AudioStreamInteractive, since it can have multiple clips playing at once.


AudioStreamPlayback get_stream_playback() 🔗

Returns the latest AudioStreamPlayback of this node, usually the most recently created by play(). If no sounds are playing, this method fails and returns an empty playback.


bool has_stream_playback() 🔗

Returns true if any sound is active, even if stream_paused is set to true. See also playing and get_stream_playback().


void play(from_position: float = 0.0) 🔗

Plays a sound from the beginning, or the given from_position in seconds.


void seek(to_position: float) 🔗

Reinicia todos los sonidos que se reproducirán desde el to_position indicado, en segundos. No hace nada si no se reproduce ningún sonido.


void stop() 🔗

Stops all sounds from this node.