AudioStreamPlayer2D¶
Inherits: Node2D < CanvasItem < Node < Object
Category: Core
Brief Description¶
Plays audio in 2D.
Properties¶
| int | area_mask |
| float | attenuation |
| bool | autoplay |
| String | bus |
| float | max_distance |
| float | pitch_scale |
| bool | playing |
| AudioStream | stream |
| bool | stream_paused |
| float | volume_db |
Methods¶
| float | get_playback_position ( ) |
| AudioStreamPlayback | get_stream_playback ( ) |
| void | play ( float from_position=0.0 ) |
| void | seek ( float to_position ) |
| void | stop ( ) |
Description¶
Plays audio that dampens with distance from screen center.
Tutorials¶
Property Descriptions¶
- int area_mask
| Setter | set_area_mask(value) |
| Getter | get_area_mask() |
Areas in which this sound plays.
- float attenuation
| Setter | set_attenuation(value) |
| Getter | get_attenuation() |
Dampens audio over distance with this as an exponent.
- bool autoplay
| Setter | set_autoplay(value) |
| Getter | is_autoplay_enabled() |
If true, audio plays when added to scene tree. Default value: false.
- String bus
| Setter | set_bus(value) |
| Getter | get_bus() |
Bus on which this audio is playing.
- float max_distance
| Setter | set_max_distance(value) |
| Getter | get_max_distance() |
Maximum distance from which audio is still hearable.
- float pitch_scale
| Setter | set_pitch_scale(value) |
| Getter | get_pitch_scale() |
Changes the pitch and the tempo of the audio.
- bool playing
| 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
| Setter | set_stream_paused(value) |
| Getter | get_stream_paused() |
- float volume_db
| 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 ( )
- 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.