class_audiostreamplayer.rst 12 KB

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