class_audiostreamplayer.rst 9.9 KB

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