AudioStreamPlayer2D¶
Inherits: Node2D < CanvasItem < Node < Object
Plays positional sound in 2D space.
Description¶
Plays audio that dampens with distance from screen center.
See also AudioStreamPlayer to play a sound non-positionally.
Note: Hiding an AudioStreamPlayer2D
node does not disable its audio output. To temporarily disable an AudioStreamPlayer2D
's audio output, set volume_db to a very low value like -100
(which isn't audible to human hearing).
Tutorials¶
Properties¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Methods¶
void |
|
void |
|
void |
stop ( ) |
Signals¶
finished ( )
Emitted when the audio stops playing.
Property Descriptions¶
int area_mask
Default |
|
Setter |
set_area_mask(value) |
Getter |
get_area_mask() |
Determines which Area2D layers affect the sound for reverb and audio bus effects. Areas can be used to redirect AudioStreams so that they play in a certain audio bus. An example of how you might use this is making a "water" area so that sounds played in the water are redirected through an audio bus to make them sound like they are being played underwater.
float attenuation
Default |
|
Setter |
set_attenuation(value) |
Getter |
get_attenuation() |
Dampens audio over distance with this as an exponent.
bool autoplay
Default |
|
Setter |
set_autoplay(value) |
Getter |
is_autoplay_enabled() |
If true
, audio plays when added to scene tree.
String bus
Default |
|
Setter |
set_bus(value) |
Getter |
get_bus() |
Bus on which this audio is playing.
float max_distance
Default |
|
Setter |
set_max_distance(value) |
Getter |
get_max_distance() |
Maximum distance from which audio is still hearable.
float pitch_scale
Default |
|
Setter |
set_pitch_scale(value) |
Getter |
get_pitch_scale() |
The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.
bool playing
Default |
|
Getter |
is_playing() |
If true
, audio is playing.
AudioStream stream
Setter |
set_stream(value) |
Getter |
get_stream() |
The AudioStream object to be played.
bool stream_paused
Default |
|
Setter |
set_stream_paused(value) |
Getter |
get_stream_paused() |
If true
, the playback is paused. You can resume it by setting stream_paused
to false
.
float volume_db
Default |
|
Setter |
set_volume_db(value) |
Getter |
get_volume_db() |
Base volume without dampening.
Method Descriptions¶
float get_playback_position ( )
Returns the position in the AudioStream.
AudioStreamPlayback get_stream_playback ( )
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.