AudioStreamPlayer2D

Inherits: Node2D < CanvasItem < Node < Object

Plays audio in 2D.

Description

Plays audio that dampens with distance from screen center.

Tutorials

Properties

intarea_mask1
floatattenuation1.0
boolautoplayfalse
Stringbus“Master”
floatmax_distance2000.0
floatpitch_scale1.0
boolplayingfalse
AudioStreamstream 
boolstream_pausedfalse
floatvolume_db0.0

Methods

floatget_playback_position ( )
AudioStreamPlaybackget_stream_playback ( )
voidplay ( float from_position=0.0 )
voidseek ( float to_position )
voidstop ( )

Signals

  • finished ( )

Emitted when the audio stops playing.

Property Descriptions

Default1
Setterset_area_mask(value)
Getterget_area_mask()

Areas in which this sound plays.


Default1.0
Setterset_attenuation(value)
Getterget_attenuation()

Dampens audio over distance with this as an exponent.


Defaultfalse
Setterset_autoplay(value)
Getteris_autoplay_enabled()

If true, audio plays when added to scene tree.


Default“Master”
Setterset_bus(value)
Getterget_bus()

Bus on which this audio is playing.


Default2000.0
Setterset_max_distance(value)
Getterget_max_distance()

Maximum distance from which audio is still hearable.


Default1.0
Setterset_pitch_scale(value)
Getterget_pitch_scale()

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


Defaultfalse
Getteris_playing()

If true, audio is playing.


Setterset_stream(value)
Getterget_stream()

The AudioStream object to be played.


Defaultfalse
Setterset_stream_paused(value)
Getterget_stream_paused()

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


Default0.0
Setterset_volume_db(value)
Getterget_volume_db()

Base volume without dampening.

Method Descriptions

  • float get_playback_position ( )

Returns the position in the AudioStream.


Returns the AudioStreamPlayback object associated with this AudioStreamPlayer2D.


  • void play ( float from_position=0.0 )

Plays the audio from the given position from_position, in seconds.


  • void seek ( float to_position )

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


  • void stop ( )

Stops the audio.