class_streamplayer.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_StreamPlayer:
  4. StreamPlayer
  5. ============
  6. **Inherits:** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. Base class for audio stream playback.
  11. Member Functions
  12. ----------------
  13. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  14. | void | :ref:`set_stream<class_StreamPlayer_set_stream>` **(** :ref:`AudioStream<class_audiostream>` stream **)** |
  15. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`AudioStream<class_audiostream>` | :ref:`get_stream<class_StreamPlayer_get_stream>` **(** **)** const |
  17. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`play<class_StreamPlayer_play>` **(** :ref:`float<class_float>` offset=0 **)** |
  19. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`stop<class_StreamPlayer_stop>` **(** **)** |
  21. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`bool<class_bool>` | :ref:`is_playing<class_StreamPlayer_is_playing>` **(** **)** const |
  23. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`set_paused<class_StreamPlayer_set_paused>` **(** :ref:`bool<class_bool>` paused **)** |
  25. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`is_paused<class_StreamPlayer_is_paused>` **(** **)** const |
  27. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`set_loop<class_StreamPlayer_set_loop>` **(** :ref:`bool<class_bool>` enabled **)** |
  29. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`has_loop<class_StreamPlayer_has_loop>` **(** **)** const |
  31. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`set_volume<class_StreamPlayer_set_volume>` **(** :ref:`float<class_float>` volume **)** |
  33. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`float<class_float>` | :ref:`get_volume<class_StreamPlayer_get_volume>` **(** **)** const |
  35. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`set_volume_db<class_StreamPlayer_set_volume_db>` **(** :ref:`float<class_float>` db **)** |
  37. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`float<class_float>` | :ref:`get_volume_db<class_StreamPlayer_get_volume_db>` **(** **)** const |
  39. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`set_buffering_msec<class_StreamPlayer_set_buffering_msec>` **(** :ref:`int<class_int>` msec **)** |
  41. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`get_buffering_msec<class_StreamPlayer_get_buffering_msec>` **(** **)** const |
  43. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`set_loop_restart_time<class_StreamPlayer_set_loop_restart_time>` **(** :ref:`float<class_float>` secs **)** |
  45. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`float<class_float>` | :ref:`get_loop_restart_time<class_StreamPlayer_get_loop_restart_time>` **(** **)** const |
  47. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`String<class_string>` | :ref:`get_stream_name<class_StreamPlayer_get_stream_name>` **(** **)** const |
  49. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`int<class_int>` | :ref:`get_loop_count<class_StreamPlayer_get_loop_count>` **(** **)** const |
  51. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`float<class_float>` | :ref:`get_pos<class_StreamPlayer_get_pos>` **(** **)** const |
  53. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`seek_pos<class_StreamPlayer_seek_pos>` **(** :ref:`float<class_float>` time **)** |
  55. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`set_autoplay<class_StreamPlayer_set_autoplay>` **(** :ref:`bool<class_bool>` enabled **)** |
  57. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`bool<class_bool>` | :ref:`has_autoplay<class_StreamPlayer_has_autoplay>` **(** **)** const |
  59. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`float<class_float>` | :ref:`get_length<class_StreamPlayer_get_length>` **(** **)** const |
  61. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------+
  62. Signals
  63. -------
  64. - **finished** **(** **)**
  65. Description
  66. -----------
  67. Base class for audio stream playback. Audio stream players inherit from it.
  68. Member Function Description
  69. ---------------------------
  70. .. _class_StreamPlayer_set_stream:
  71. - void **set_stream** **(** :ref:`AudioStream<class_audiostream>` stream **)**
  72. Set the :ref:`EventStream<class_eventstream>` this player will play.
  73. .. _class_StreamPlayer_get_stream:
  74. - :ref:`AudioStream<class_audiostream>` **get_stream** **(** **)** const
  75. Return the currently assigned stream.
  76. .. _class_StreamPlayer_play:
  77. - void **play** **(** :ref:`float<class_float>` offset=0 **)**
  78. Play the currently assigned stream, starting from a given position (in seconds).
  79. .. _class_StreamPlayer_stop:
  80. - void **stop** **(** **)**
  81. Stop the playback.
  82. .. _class_StreamPlayer_is_playing:
  83. - :ref:`bool<class_bool>` **is_playing** **(** **)** const
  84. Return whether this player is playing.
  85. .. _class_StreamPlayer_set_paused:
  86. - void **set_paused** **(** :ref:`bool<class_bool>` paused **)**
  87. Pause stream playback.
  88. .. _class_StreamPlayer_is_paused:
  89. - :ref:`bool<class_bool>` **is_paused** **(** **)** const
  90. Return whether the playback is currently paused.
  91. .. _class_StreamPlayer_set_loop:
  92. - void **set_loop** **(** :ref:`bool<class_bool>` enabled **)**
  93. Set whether the stream will be restarted at the end.
  94. .. _class_StreamPlayer_has_loop:
  95. - :ref:`bool<class_bool>` **has_loop** **(** **)** const
  96. Return whether the stream will be restarted at the end.
  97. .. _class_StreamPlayer_set_volume:
  98. - void **set_volume** **(** :ref:`float<class_float>` volume **)**
  99. Set the playback volume for this player. This is a float between 0.0 (silent) and 1.0 (full volume). Values over 1.0 will amplify sound even more, but may introduce distortion. Negative values will just invert the output waveform, which produces no audible difference.
  100. .. _class_StreamPlayer_get_volume:
  101. - :ref:`float<class_float>` **get_volume** **(** **)** const
  102. Return the playback volume for this player.
  103. .. _class_StreamPlayer_set_volume_db:
  104. - void **set_volume_db** **(** :ref:`float<class_float>` db **)**
  105. Set the playback volume for this player, in decibels. This is a float between -80.0 (silent) and 0.0 (full volume). Values under -79.0 get truncated to -80, but values over 0.0 do not, so the warnings for overamplifying (see :ref:`set_volume<class_StreamPlayer_set_volume>`) still apply.
  106. .. _class_StreamPlayer_get_volume_db:
  107. - :ref:`float<class_float>` **get_volume_db** **(** **)** const
  108. Return the playback volume for this player, in decibels.
  109. .. _class_StreamPlayer_set_buffering_msec:
  110. - void **set_buffering_msec** **(** :ref:`int<class_int>` msec **)**
  111. Set the size (in milliseconds) of the audio buffer. A long audio buffer protects better against slowdowns, but responds worse to changes (in volume, stream played...). A shorter buffer takes less time to respond to changes, but may stutter if the application suffers some slowdown.
  112. Default is 500 milliseconds.
  113. .. _class_StreamPlayer_get_buffering_msec:
  114. - :ref:`int<class_int>` **get_buffering_msec** **(** **)** const
  115. Return the size of the audio buffer.
  116. .. _class_StreamPlayer_set_loop_restart_time:
  117. - void **set_loop_restart_time** **(** :ref:`float<class_float>` secs **)**
  118. Set the point in time the stream will rewind to, when looping.
  119. .. _class_StreamPlayer_get_loop_restart_time:
  120. - :ref:`float<class_float>` **get_loop_restart_time** **(** **)** const
  121. Return the point in time the stream will rewind to, when looping.
  122. .. _class_StreamPlayer_get_stream_name:
  123. - :ref:`String<class_string>` **get_stream_name** **(** **)** const
  124. Return the name of the currently assigned stream. This is not the file name, but a field inside the file. If no stream is assigned, if returns "<No Stream>".
  125. .. _class_StreamPlayer_get_loop_count:
  126. - :ref:`int<class_int>` **get_loop_count** **(** **)** const
  127. Return the number of times the playback has looped.
  128. .. _class_StreamPlayer_get_pos:
  129. - :ref:`float<class_float>` **get_pos** **(** **)** const
  130. Return the playback position, in seconds.
  131. .. _class_StreamPlayer_seek_pos:
  132. - void **seek_pos** **(** :ref:`float<class_float>` time **)**
  133. Set the playback position, in seconds.
  134. .. _class_StreamPlayer_set_autoplay:
  135. - void **set_autoplay** **(** :ref:`bool<class_bool>` enabled **)**
  136. Set whether this player will start playing as soon as it enters the scene tree.
  137. .. _class_StreamPlayer_has_autoplay:
  138. - :ref:`bool<class_bool>` **has_autoplay** **(** **)** const
  139. Return whether this player will start playing as soon as it enters the scene tree.
  140. .. _class_StreamPlayer_get_length:
  141. - :ref:`float<class_float>` **get_length** **(** **)** const
  142. Return the length of the stream, in seconds.