:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/AudioStreamPlayer.xml. .. _class_AudioStreamPlayer: AudioStreamPlayer ================= **Inherits:** :ref:`Node` **<** :ref:`Object` Plays back audio non-positionally. .. rst-class:: classref-introduction-group Description ----------- Plays an audio stream non-positionally. To play audio positionally, use :ref:`AudioStreamPlayer2D` or :ref:`AudioStreamPlayer3D` instead of **AudioStreamPlayer**. .. rst-class:: classref-introduction-group Tutorials --------- - :doc:`Audio streams <../tutorials/audio/audio_streams>` - `2D Dodge The Creeps Demo `__ - `Audio Device Changer Demo `__ - `Audio Generator Demo `__ - `Audio Mic Record Demo `__ - `Audio Spectrum Demo `__ .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +----------------------------------------------------+----------------------------------------------------------------------+--------------+ | :ref:`bool` | :ref:`autoplay` | ``false`` | +----------------------------------------------------+----------------------------------------------------------------------+--------------+ | :ref:`String` | :ref:`bus` | ``"Master"`` | +----------------------------------------------------+----------------------------------------------------------------------+--------------+ | :ref:`MixTarget` | :ref:`mix_target` | ``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`` | +----------------------------------------------------+----------------------------------------------------------------------+--------------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +-------------------------------------------------------+----------------------------------------------------------------------------------------------------------+ | :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` **(** **)** | +-------------------------------------------------------+----------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Signals ------- .. _class_AudioStreamPlayer_signal_finished: .. rst-class:: classref-signal **finished** **(** **)** Emitted when the audio stops playing. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Enumerations ------------ .. _enum_AudioStreamPlayer_MixTarget: .. rst-class:: classref-enumeration enum **MixTarget**: .. _class_AudioStreamPlayer_constant_MIX_TARGET_STEREO: .. rst-class:: classref-enumeration-constant :ref:`MixTarget` **MIX_TARGET_STEREO** = ``0`` The audio will be played only on the first channel. .. _class_AudioStreamPlayer_constant_MIX_TARGET_SURROUND: .. rst-class:: classref-enumeration-constant :ref:`MixTarget` **MIX_TARGET_SURROUND** = ``1`` The audio will be played on all surround channels. .. _class_AudioStreamPlayer_constant_MIX_TARGET_CENTER: .. rst-class:: classref-enumeration-constant :ref:`MixTarget` **MIX_TARGET_CENTER** = ``2`` The audio will be played on the second channel, which is usually the center. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_AudioStreamPlayer_property_autoplay: .. rst-class:: classref-property :ref:`bool` **autoplay** = ``false`` .. rst-class:: classref-property-setget - void **set_autoplay** **(** :ref:`bool` value **)** - :ref:`bool` **is_autoplay_enabled** **(** **)** If ``true``, audio plays when added to scene tree. .. rst-class:: classref-item-separator ---- .. _class_AudioStreamPlayer_property_bus: .. rst-class:: classref-property :ref:`String` **bus** = ``"Master"`` .. rst-class:: classref-property-setget - void **set_bus** **(** :ref:`String` value **)** - :ref:`String` **get_bus** **(** **)** Bus on which this audio is playing. \ **Note:** When setting this property, keep in mind that no validation is performed to see if the given name matches an existing bus. This is because audio bus layouts might be loaded after this property is set. If this given name can't be resolved at runtime, it will fall back to ``"Master"``. .. rst-class:: classref-item-separator ---- .. _class_AudioStreamPlayer_property_mix_target: .. rst-class:: classref-property :ref:`MixTarget` **mix_target** = ``0`` .. rst-class:: classref-property-setget - void **set_mix_target** **(** :ref:`MixTarget` value **)** - :ref:`MixTarget` **get_mix_target** **(** **)** If the audio configuration has more than two speakers, this sets the target channels. See :ref:`MixTarget` constants. .. rst-class:: classref-item-separator ---- .. _class_AudioStreamPlayer_property_pitch_scale: .. rst-class:: classref-property :ref:`float` **pitch_scale** = ``1.0`` .. rst-class:: classref-property-setget - void **set_pitch_scale** **(** :ref:`float` value **)** - :ref:`float` **get_pitch_scale** **(** **)** The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate. .. rst-class:: classref-item-separator ---- .. _class_AudioStreamPlayer_property_playing: .. rst-class:: classref-property :ref:`bool` **playing** = ``false`` .. rst-class:: classref-property-setget - :ref:`bool` **is_playing** **(** **)** If ``true``, audio is playing. .. rst-class:: classref-item-separator ---- .. _class_AudioStreamPlayer_property_stream: .. rst-class:: classref-property :ref:`AudioStream` **stream** .. rst-class:: classref-property-setget - void **set_stream** **(** :ref:`AudioStream` value **)** - :ref:`AudioStream` **get_stream** **(** **)** The :ref:`AudioStream` object to be played. .. rst-class:: classref-item-separator ---- .. _class_AudioStreamPlayer_property_stream_paused: .. rst-class:: classref-property :ref:`bool` **stream_paused** = ``false`` .. rst-class:: classref-property-setget - void **set_stream_paused** **(** :ref:`bool` value **)** - :ref:`bool` **get_stream_paused** **(** **)** If ``true``, the playback is paused. You can resume it by setting ``stream_paused`` to ``false``. .. rst-class:: classref-item-separator ---- .. _class_AudioStreamPlayer_property_volume_db: .. rst-class:: classref-property :ref:`float` **volume_db** = ``0.0`` .. rst-class:: classref-property-setget - void **set_volume_db** **(** :ref:`float` value **)** - :ref:`float` **get_volume_db** **(** **)** Volume of sound, in dB. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_AudioStreamPlayer_method_get_playback_position: .. rst-class:: classref-method :ref:`float` **get_playback_position** **(** **)** Returns the position in the :ref:`AudioStream` in seconds. .. rst-class:: classref-item-separator ---- .. _class_AudioStreamPlayer_method_get_stream_playback: .. rst-class:: classref-method :ref:`AudioStreamPlayback` **get_stream_playback** **(** **)** Returns the :ref:`AudioStreamPlayback` object associated with this **AudioStreamPlayer**. .. rst-class:: classref-item-separator ---- .. _class_AudioStreamPlayer_method_play: .. rst-class:: classref-method void **play** **(** :ref:`float` from_position=0.0 **)** Plays the audio from the given ``from_position``, in seconds. .. rst-class:: classref-item-separator ---- .. _class_AudioStreamPlayer_method_seek: .. rst-class:: classref-method void **seek** **(** :ref:`float` to_position **)** Sets the position from which audio will be played, in seconds. .. rst-class:: classref-item-separator ---- .. _class_AudioStreamPlayer_method_stop: .. rst-class:: classref-method 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.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`