:github_url: hide .. Generated automatically by doc/tools/make_rst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the AudioStreamPlayer2D.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_AudioStreamPlayer2D: AudioStreamPlayer2D =================== **Inherits:** :ref:`Node2D` **<** :ref:`CanvasItem` **<** :ref:`Node` **<** :ref:`Object` Plays positional sound in 2D space. Description ----------- Plays audio that dampens with distance from screen center. See also :ref:`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 :ref:`volume_db` to a very low value like ``-100`` (which isn't audible to human hearing). Tutorials --------- - :doc:`../tutorials/audio/audio_streams` Properties ---------- +---------------------------------------+------------------------------------------------------------------------+--------------+ | :ref:`int` | :ref:`area_mask` | ``1`` | +---------------------------------------+------------------------------------------------------------------------+--------------+ | :ref:`float` | :ref:`attenuation` | ``1.0`` | +---------------------------------------+------------------------------------------------------------------------+--------------+ | :ref:`bool` | :ref:`autoplay` | ``false`` | +---------------------------------------+------------------------------------------------------------------------+--------------+ | :ref:`String` | :ref:`bus` | ``"Master"`` | +---------------------------------------+------------------------------------------------------------------------+--------------+ | :ref:`float` | :ref:`max_distance` | ``2000.0`` | +---------------------------------------+------------------------------------------------------------------------+--------------+ | :ref:`float` | :ref:`pitch_scale` | ``1.0`` | +---------------------------------------+------------------------------------------------------------------------+--------------+ | :ref:`bool` | :ref:`playing` | ``false`` | +---------------------------------------+------------------------------------------------------------------------+--------------+ | :ref:`AudioStream` | :ref:`stream` | | +---------------------------------------+------------------------------------------------------------------------+--------------+ | :ref:`bool` | :ref:`stream_paused` | ``false`` | +---------------------------------------+------------------------------------------------------------------------+--------------+ | :ref:`float` | :ref:`volume_db` | ``0.0`` | +---------------------------------------+------------------------------------------------------------------------+--------------+ Methods ------- +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_playback_position` **(** **)** | +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+ | :ref:`AudioStreamPlayback` | :ref:`get_stream_playback` **(** **)** | +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+ | void | :ref:`play` **(** :ref:`float` from_position=0.0 **)** | +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+ | void | :ref:`seek` **(** :ref:`float` to_position **)** | +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+ | void | :ref:`stop` **(** **)** | +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+ Signals ------- .. _class_AudioStreamPlayer2D_signal_finished: - **finished** **(** **)** Emitted when the audio stops playing. Property Descriptions --------------------- .. _class_AudioStreamPlayer2D_property_area_mask: - :ref:`int` **area_mask** +-----------+----------------------+ | *Default* | ``1`` | +-----------+----------------------+ | *Setter* | set_area_mask(value) | +-----------+----------------------+ | *Getter* | get_area_mask() | +-----------+----------------------+ Determines which :ref:`Area2D` layers affect the sound for reverb and audio bus effects. Areas can be used to redirect :ref:`AudioStream`\ s 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. ---- .. _class_AudioStreamPlayer2D_property_attenuation: - :ref:`float` **attenuation** +-----------+------------------------+ | *Default* | ``1.0`` | +-----------+------------------------+ | *Setter* | set_attenuation(value) | +-----------+------------------------+ | *Getter* | get_attenuation() | +-----------+------------------------+ Dampens audio over distance with this as an exponent. ---- .. _class_AudioStreamPlayer2D_property_autoplay: - :ref:`bool` **autoplay** +-----------+-----------------------+ | *Default* | ``false`` | +-----------+-----------------------+ | *Setter* | set_autoplay(value) | +-----------+-----------------------+ | *Getter* | is_autoplay_enabled() | +-----------+-----------------------+ If ``true``, audio plays when added to scene tree. ---- .. _class_AudioStreamPlayer2D_property_bus: - :ref:`String` **bus** +-----------+----------------+ | *Default* | ``"Master"`` | +-----------+----------------+ | *Setter* | set_bus(value) | +-----------+----------------+ | *Getter* | get_bus() | +-----------+----------------+ Bus on which this audio is playing. ---- .. _class_AudioStreamPlayer2D_property_max_distance: - :ref:`float` **max_distance** +-----------+-------------------------+ | *Default* | ``2000.0`` | +-----------+-------------------------+ | *Setter* | set_max_distance(value) | +-----------+-------------------------+ | *Getter* | get_max_distance() | +-----------+-------------------------+ Maximum distance from which audio is still hearable. ---- .. _class_AudioStreamPlayer2D_property_pitch_scale: - :ref:`float` **pitch_scale** +-----------+------------------------+ | *Default* | ``1.0`` | +-----------+------------------------+ | *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. ---- .. _class_AudioStreamPlayer2D_property_playing: - :ref:`bool` **playing** +-----------+--------------+ | *Default* | ``false`` | +-----------+--------------+ | *Getter* | is_playing() | +-----------+--------------+ If ``true``, audio is playing. ---- .. _class_AudioStreamPlayer2D_property_stream: - :ref:`AudioStream` **stream** +----------+-------------------+ | *Setter* | set_stream(value) | +----------+-------------------+ | *Getter* | get_stream() | +----------+-------------------+ The :ref:`AudioStream` object to be played. ---- .. _class_AudioStreamPlayer2D_property_stream_paused: - :ref:`bool` **stream_paused** +-----------+--------------------------+ | *Default* | ``false`` | +-----------+--------------------------+ | *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``. ---- .. _class_AudioStreamPlayer2D_property_volume_db: - :ref:`float` **volume_db** +-----------+----------------------+ | *Default* | ``0.0`` | +-----------+----------------------+ | *Setter* | set_volume_db(value) | +-----------+----------------------+ | *Getter* | get_volume_db() | +-----------+----------------------+ Base volume without dampening. Method Descriptions ------------------- .. _class_AudioStreamPlayer2D_method_get_playback_position: - :ref:`float` **get_playback_position** **(** **)** Returns the position in the :ref:`AudioStream`. ---- .. _class_AudioStreamPlayer2D_method_get_stream_playback: - :ref:`AudioStreamPlayback` **get_stream_playback** **(** **)** Returns the :ref:`AudioStreamPlayback` object associated with this ``AudioStreamPlayer2D``. ---- .. _class_AudioStreamPlayer2D_method_play: - void **play** **(** :ref:`float` from_position=0.0 **)** Plays the audio from the given position ``from_position``, in seconds. ---- .. _class_AudioStreamPlayer2D_method_seek: - void **seek** **(** :ref:`float` to_position **)** Sets the position from which audio will be played, in seconds. ---- .. _class_AudioStreamPlayer2D_method_stop: - void **stop** **(** **)** Stops the audio. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`