class_audiostreamplayer.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the AudioStreamPlayer.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_AudioStreamPlayer:
  6. AudioStreamPlayer
  7. =================
  8. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Plays back audio non-positionally.
  10. Description
  11. -----------
  12. Plays an audio stream non-positionally.
  13. To play audio positionally, use :ref:`AudioStreamPlayer2D<class_AudioStreamPlayer2D>` or :ref:`AudioStreamPlayer3D<class_AudioStreamPlayer3D>` instead of ``AudioStreamPlayer``.
  14. Tutorials
  15. ---------
  16. - :doc:`../tutorials/audio/audio_streams`
  17. - `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
  18. - `Audio Device Changer Demo <https://godotengine.org/asset-library/asset/525>`__
  19. - `Audio Generator Demo <https://godotengine.org/asset-library/asset/526>`__
  20. - `Audio Mic Record Demo <https://godotengine.org/asset-library/asset/527>`__
  21. - `Audio Spectrum Demo <https://godotengine.org/asset-library/asset/528>`__
  22. Properties
  23. ----------
  24. +----------------------------------------------------+----------------------------------------------------------------------+--------------+
  25. | :ref:`bool<class_bool>` | :ref:`autoplay<class_AudioStreamPlayer_property_autoplay>` | ``false`` |
  26. +----------------------------------------------------+----------------------------------------------------------------------+--------------+
  27. | :ref:`String<class_String>` | :ref:`bus<class_AudioStreamPlayer_property_bus>` | ``"Master"`` |
  28. +----------------------------------------------------+----------------------------------------------------------------------+--------------+
  29. | :ref:`MixTarget<enum_AudioStreamPlayer_MixTarget>` | :ref:`mix_target<class_AudioStreamPlayer_property_mix_target>` | ``0`` |
  30. +----------------------------------------------------+----------------------------------------------------------------------+--------------+
  31. | :ref:`float<class_float>` | :ref:`pitch_scale<class_AudioStreamPlayer_property_pitch_scale>` | ``1.0`` |
  32. +----------------------------------------------------+----------------------------------------------------------------------+--------------+
  33. | :ref:`bool<class_bool>` | :ref:`playing<class_AudioStreamPlayer_property_playing>` | ``false`` |
  34. +----------------------------------------------------+----------------------------------------------------------------------+--------------+
  35. | :ref:`AudioStream<class_AudioStream>` | :ref:`stream<class_AudioStreamPlayer_property_stream>` | |
  36. +----------------------------------------------------+----------------------------------------------------------------------+--------------+
  37. | :ref:`bool<class_bool>` | :ref:`stream_paused<class_AudioStreamPlayer_property_stream_paused>` | ``false`` |
  38. +----------------------------------------------------+----------------------------------------------------------------------+--------------+
  39. | :ref:`float<class_float>` | :ref:`volume_db<class_AudioStreamPlayer_property_volume_db>` | ``0.0`` |
  40. +----------------------------------------------------+----------------------------------------------------------------------+--------------+
  41. Methods
  42. -------
  43. +-------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
  44. | :ref:`float<class_float>` | :ref:`get_playback_position<class_AudioStreamPlayer_method_get_playback_position>` **(** **)** |
  45. +-------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
  46. | :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` | :ref:`get_stream_playback<class_AudioStreamPlayer_method_get_stream_playback>` **(** **)** |
  47. +-------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`play<class_AudioStreamPlayer_method_play>` **(** :ref:`float<class_float>` from_position=0.0 **)** |
  49. +-------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`seek<class_AudioStreamPlayer_method_seek>` **(** :ref:`float<class_float>` to_position **)** |
  51. +-------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`stop<class_AudioStreamPlayer_method_stop>` **(** **)** |
  53. +-------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
  54. Signals
  55. -------
  56. .. _class_AudioStreamPlayer_signal_finished:
  57. - **finished** **(** **)**
  58. Emitted when the audio stops playing.
  59. Enumerations
  60. ------------
  61. .. _enum_AudioStreamPlayer_MixTarget:
  62. .. _class_AudioStreamPlayer_constant_MIX_TARGET_STEREO:
  63. .. _class_AudioStreamPlayer_constant_MIX_TARGET_SURROUND:
  64. .. _class_AudioStreamPlayer_constant_MIX_TARGET_CENTER:
  65. enum **MixTarget**:
  66. - **MIX_TARGET_STEREO** = **0** --- The audio will be played only on the first channel.
  67. - **MIX_TARGET_SURROUND** = **1** --- The audio will be played on all surround channels.
  68. - **MIX_TARGET_CENTER** = **2** --- The audio will be played on the second channel, which is usually the center.
  69. Property Descriptions
  70. ---------------------
  71. .. _class_AudioStreamPlayer_property_autoplay:
  72. - :ref:`bool<class_bool>` **autoplay**
  73. +-----------+-----------------------+
  74. | *Default* | ``false`` |
  75. +-----------+-----------------------+
  76. | *Setter* | set_autoplay(value) |
  77. +-----------+-----------------------+
  78. | *Getter* | is_autoplay_enabled() |
  79. +-----------+-----------------------+
  80. If ``true``, audio plays when added to scene tree.
  81. ----
  82. .. _class_AudioStreamPlayer_property_bus:
  83. - :ref:`String<class_String>` **bus**
  84. +-----------+----------------+
  85. | *Default* | ``"Master"`` |
  86. +-----------+----------------+
  87. | *Setter* | set_bus(value) |
  88. +-----------+----------------+
  89. | *Getter* | get_bus() |
  90. +-----------+----------------+
  91. Bus on which this audio is playing.
  92. ----
  93. .. _class_AudioStreamPlayer_property_mix_target:
  94. - :ref:`MixTarget<enum_AudioStreamPlayer_MixTarget>` **mix_target**
  95. +-----------+-----------------------+
  96. | *Default* | ``0`` |
  97. +-----------+-----------------------+
  98. | *Setter* | set_mix_target(value) |
  99. +-----------+-----------------------+
  100. | *Getter* | get_mix_target() |
  101. +-----------+-----------------------+
  102. If the audio configuration has more than two speakers, this sets the target channels. See :ref:`MixTarget<enum_AudioStreamPlayer_MixTarget>` constants.
  103. ----
  104. .. _class_AudioStreamPlayer_property_pitch_scale:
  105. - :ref:`float<class_float>` **pitch_scale**
  106. +-----------+------------------------+
  107. | *Default* | ``1.0`` |
  108. +-----------+------------------------+
  109. | *Setter* | set_pitch_scale(value) |
  110. +-----------+------------------------+
  111. | *Getter* | get_pitch_scale() |
  112. +-----------+------------------------+
  113. The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.
  114. ----
  115. .. _class_AudioStreamPlayer_property_playing:
  116. - :ref:`bool<class_bool>` **playing**
  117. +-----------+--------------+
  118. | *Default* | ``false`` |
  119. +-----------+--------------+
  120. | *Getter* | is_playing() |
  121. +-----------+--------------+
  122. If ``true``, audio is playing.
  123. ----
  124. .. _class_AudioStreamPlayer_property_stream:
  125. - :ref:`AudioStream<class_AudioStream>` **stream**
  126. +----------+-------------------+
  127. | *Setter* | set_stream(value) |
  128. +----------+-------------------+
  129. | *Getter* | get_stream() |
  130. +----------+-------------------+
  131. The :ref:`AudioStream<class_AudioStream>` object to be played.
  132. ----
  133. .. _class_AudioStreamPlayer_property_stream_paused:
  134. - :ref:`bool<class_bool>` **stream_paused**
  135. +-----------+--------------------------+
  136. | *Default* | ``false`` |
  137. +-----------+--------------------------+
  138. | *Setter* | set_stream_paused(value) |
  139. +-----------+--------------------------+
  140. | *Getter* | get_stream_paused() |
  141. +-----------+--------------------------+
  142. If ``true``, the playback is paused. You can resume it by setting ``stream_paused`` to ``false``.
  143. ----
  144. .. _class_AudioStreamPlayer_property_volume_db:
  145. - :ref:`float<class_float>` **volume_db**
  146. +-----------+----------------------+
  147. | *Default* | ``0.0`` |
  148. +-----------+----------------------+
  149. | *Setter* | set_volume_db(value) |
  150. +-----------+----------------------+
  151. | *Getter* | get_volume_db() |
  152. +-----------+----------------------+
  153. Volume of sound, in dB.
  154. Method Descriptions
  155. -------------------
  156. .. _class_AudioStreamPlayer_method_get_playback_position:
  157. - :ref:`float<class_float>` **get_playback_position** **(** **)**
  158. Returns the position in the :ref:`AudioStream<class_AudioStream>` in seconds.
  159. ----
  160. .. _class_AudioStreamPlayer_method_get_stream_playback:
  161. - :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` **get_stream_playback** **(** **)**
  162. Returns the :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` object associated with this ``AudioStreamPlayer``.
  163. ----
  164. .. _class_AudioStreamPlayer_method_play:
  165. - void **play** **(** :ref:`float<class_float>` from_position=0.0 **)**
  166. Plays the audio from the given ``from_position``, in seconds.
  167. ----
  168. .. _class_AudioStreamPlayer_method_seek:
  169. - void **seek** **(** :ref:`float<class_float>` to_position **)**
  170. Sets the position from which audio will be played, in seconds.
  171. ----
  172. .. _class_AudioStreamPlayer_method_stop:
  173. - void **stop** **(** **)**
  174. Stops the audio.
  175. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  176. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  177. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`