class_audiostreamplayer2d.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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 AudioStreamPlayer2D.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_AudioStreamPlayer2D:
  6. AudioStreamPlayer2D
  7. ===================
  8. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Plays audio in 2D.
  10. Description
  11. -----------
  12. Plays audio that dampens with distance from screen center.
  13. Tutorials
  14. ---------
  15. - :doc:`../tutorials/audio/audio_streams`
  16. Properties
  17. ----------
  18. +---------------------------------------+------------------------------------------------------------------------+--------------+
  19. | :ref:`int<class_int>` | :ref:`area_mask<class_AudioStreamPlayer2D_property_area_mask>` | ``1`` |
  20. +---------------------------------------+------------------------------------------------------------------------+--------------+
  21. | :ref:`float<class_float>` | :ref:`attenuation<class_AudioStreamPlayer2D_property_attenuation>` | ``1.0`` |
  22. +---------------------------------------+------------------------------------------------------------------------+--------------+
  23. | :ref:`bool<class_bool>` | :ref:`autoplay<class_AudioStreamPlayer2D_property_autoplay>` | ``false`` |
  24. +---------------------------------------+------------------------------------------------------------------------+--------------+
  25. | :ref:`String<class_String>` | :ref:`bus<class_AudioStreamPlayer2D_property_bus>` | ``"Master"`` |
  26. +---------------------------------------+------------------------------------------------------------------------+--------------+
  27. | :ref:`float<class_float>` | :ref:`max_distance<class_AudioStreamPlayer2D_property_max_distance>` | ``2000.0`` |
  28. +---------------------------------------+------------------------------------------------------------------------+--------------+
  29. | :ref:`float<class_float>` | :ref:`pitch_scale<class_AudioStreamPlayer2D_property_pitch_scale>` | ``1.0`` |
  30. +---------------------------------------+------------------------------------------------------------------------+--------------+
  31. | :ref:`bool<class_bool>` | :ref:`playing<class_AudioStreamPlayer2D_property_playing>` | ``false`` |
  32. +---------------------------------------+------------------------------------------------------------------------+--------------+
  33. | :ref:`AudioStream<class_AudioStream>` | :ref:`stream<class_AudioStreamPlayer2D_property_stream>` | |
  34. +---------------------------------------+------------------------------------------------------------------------+--------------+
  35. | :ref:`bool<class_bool>` | :ref:`stream_paused<class_AudioStreamPlayer2D_property_stream_paused>` | ``false`` |
  36. +---------------------------------------+------------------------------------------------------------------------+--------------+
  37. | :ref:`float<class_float>` | :ref:`volume_db<class_AudioStreamPlayer2D_property_volume_db>` | ``0.0`` |
  38. +---------------------------------------+------------------------------------------------------------------------+--------------+
  39. Methods
  40. -------
  41. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  42. | :ref:`float<class_float>` | :ref:`get_playback_position<class_AudioStreamPlayer2D_method_get_playback_position>` **(** **)** |
  43. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  44. | :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` | :ref:`get_stream_playback<class_AudioStreamPlayer2D_method_get_stream_playback>` **(** **)** |
  45. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`play<class_AudioStreamPlayer2D_method_play>` **(** :ref:`float<class_float>` from_position=0.0 **)** |
  47. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`seek<class_AudioStreamPlayer2D_method_seek>` **(** :ref:`float<class_float>` to_position **)** |
  49. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`stop<class_AudioStreamPlayer2D_method_stop>` **(** **)** |
  51. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  52. Signals
  53. -------
  54. .. _class_AudioStreamPlayer2D_signal_finished:
  55. - **finished** **(** **)**
  56. Emitted when the audio stops playing.
  57. Property Descriptions
  58. ---------------------
  59. .. _class_AudioStreamPlayer2D_property_area_mask:
  60. - :ref:`int<class_int>` **area_mask**
  61. +-----------+----------------------+
  62. | *Default* | ``1`` |
  63. +-----------+----------------------+
  64. | *Setter* | set_area_mask(value) |
  65. +-----------+----------------------+
  66. | *Getter* | get_area_mask() |
  67. +-----------+----------------------+
  68. Areas in which this sound plays.
  69. ----
  70. .. _class_AudioStreamPlayer2D_property_attenuation:
  71. - :ref:`float<class_float>` **attenuation**
  72. +-----------+------------------------+
  73. | *Default* | ``1.0`` |
  74. +-----------+------------------------+
  75. | *Setter* | set_attenuation(value) |
  76. +-----------+------------------------+
  77. | *Getter* | get_attenuation() |
  78. +-----------+------------------------+
  79. Dampens audio over distance with this as an exponent.
  80. ----
  81. .. _class_AudioStreamPlayer2D_property_autoplay:
  82. - :ref:`bool<class_bool>` **autoplay**
  83. +-----------+-----------------------+
  84. | *Default* | ``false`` |
  85. +-----------+-----------------------+
  86. | *Setter* | set_autoplay(value) |
  87. +-----------+-----------------------+
  88. | *Getter* | is_autoplay_enabled() |
  89. +-----------+-----------------------+
  90. If ``true``, audio plays when added to scene tree.
  91. ----
  92. .. _class_AudioStreamPlayer2D_property_bus:
  93. - :ref:`String<class_String>` **bus**
  94. +-----------+----------------+
  95. | *Default* | ``"Master"`` |
  96. +-----------+----------------+
  97. | *Setter* | set_bus(value) |
  98. +-----------+----------------+
  99. | *Getter* | get_bus() |
  100. +-----------+----------------+
  101. Bus on which this audio is playing.
  102. ----
  103. .. _class_AudioStreamPlayer2D_property_max_distance:
  104. - :ref:`float<class_float>` **max_distance**
  105. +-----------+-------------------------+
  106. | *Default* | ``2000.0`` |
  107. +-----------+-------------------------+
  108. | *Setter* | set_max_distance(value) |
  109. +-----------+-------------------------+
  110. | *Getter* | get_max_distance() |
  111. +-----------+-------------------------+
  112. Maximum distance from which audio is still hearable.
  113. ----
  114. .. _class_AudioStreamPlayer2D_property_pitch_scale:
  115. - :ref:`float<class_float>` **pitch_scale**
  116. +-----------+------------------------+
  117. | *Default* | ``1.0`` |
  118. +-----------+------------------------+
  119. | *Setter* | set_pitch_scale(value) |
  120. +-----------+------------------------+
  121. | *Getter* | get_pitch_scale() |
  122. +-----------+------------------------+
  123. The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.
  124. ----
  125. .. _class_AudioStreamPlayer2D_property_playing:
  126. - :ref:`bool<class_bool>` **playing**
  127. +-----------+--------------+
  128. | *Default* | ``false`` |
  129. +-----------+--------------+
  130. | *Getter* | is_playing() |
  131. +-----------+--------------+
  132. If ``true``, audio is playing.
  133. ----
  134. .. _class_AudioStreamPlayer2D_property_stream:
  135. - :ref:`AudioStream<class_AudioStream>` **stream**
  136. +----------+-------------------+
  137. | *Setter* | set_stream(value) |
  138. +----------+-------------------+
  139. | *Getter* | get_stream() |
  140. +----------+-------------------+
  141. The :ref:`AudioStream<class_AudioStream>` object to be played.
  142. ----
  143. .. _class_AudioStreamPlayer2D_property_stream_paused:
  144. - :ref:`bool<class_bool>` **stream_paused**
  145. +-----------+--------------------------+
  146. | *Default* | ``false`` |
  147. +-----------+--------------------------+
  148. | *Setter* | set_stream_paused(value) |
  149. +-----------+--------------------------+
  150. | *Getter* | get_stream_paused() |
  151. +-----------+--------------------------+
  152. If ``true``, the playback is paused. You can resume it by setting ``stream_paused`` to ``false``.
  153. ----
  154. .. _class_AudioStreamPlayer2D_property_volume_db:
  155. - :ref:`float<class_float>` **volume_db**
  156. +-----------+----------------------+
  157. | *Default* | ``0.0`` |
  158. +-----------+----------------------+
  159. | *Setter* | set_volume_db(value) |
  160. +-----------+----------------------+
  161. | *Getter* | get_volume_db() |
  162. +-----------+----------------------+
  163. Base volume without dampening.
  164. Method Descriptions
  165. -------------------
  166. .. _class_AudioStreamPlayer2D_method_get_playback_position:
  167. - :ref:`float<class_float>` **get_playback_position** **(** **)**
  168. Returns the position in the :ref:`AudioStream<class_AudioStream>`.
  169. ----
  170. .. _class_AudioStreamPlayer2D_method_get_stream_playback:
  171. - :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` **get_stream_playback** **(** **)**
  172. Returns the :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` object associated with this ``AudioStreamPlayer2D``.
  173. ----
  174. .. _class_AudioStreamPlayer2D_method_play:
  175. - void **play** **(** :ref:`float<class_float>` from_position=0.0 **)**
  176. Plays the audio from the given position ``from_position``, in seconds.
  177. ----
  178. .. _class_AudioStreamPlayer2D_method_seek:
  179. - void **seek** **(** :ref:`float<class_float>` to_position **)**
  180. Sets the position from which audio will be played, in seconds.
  181. ----
  182. .. _class_AudioStreamPlayer2D_method_stop:
  183. - void **stop** **(** **)**
  184. Stops the audio.
  185. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  186. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  187. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`