class_videoplayer.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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 VideoPlayer.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_VideoPlayer:
  6. VideoPlayer
  7. ===========
  8. **Inherits:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Control for playing video streams.
  10. Description
  11. -----------
  12. Control node for playing video streams using :ref:`VideoStream<class_VideoStream>` resources.
  13. Supported video formats are `WebM <https://www.webmproject.org/>`_ (:ref:`VideoStreamWebm<class_VideoStreamWebm>`), `Ogg Theora <https://www.theora.org/>`_ (:ref:`VideoStreamTheora<class_VideoStreamTheora>`), and any format exposed via a GDNative plugin using :ref:`VideoStreamGDNative<class_VideoStreamGDNative>`.
  14. Properties
  15. ----------
  16. +---------------------------------------+--------------------------------------------------------------------+--------------+
  17. | :ref:`int<class_int>` | :ref:`audio_track<class_VideoPlayer_property_audio_track>` | ``0`` |
  18. +---------------------------------------+--------------------------------------------------------------------+--------------+
  19. | :ref:`bool<class_bool>` | :ref:`autoplay<class_VideoPlayer_property_autoplay>` | ``false`` |
  20. +---------------------------------------+--------------------------------------------------------------------+--------------+
  21. | :ref:`int<class_int>` | :ref:`buffering_msec<class_VideoPlayer_property_buffering_msec>` | ``500`` |
  22. +---------------------------------------+--------------------------------------------------------------------+--------------+
  23. | :ref:`String<class_String>` | :ref:`bus<class_VideoPlayer_property_bus>` | ``"Master"`` |
  24. +---------------------------------------+--------------------------------------------------------------------+--------------+
  25. | :ref:`bool<class_bool>` | :ref:`expand<class_VideoPlayer_property_expand>` | ``true`` |
  26. +---------------------------------------+--------------------------------------------------------------------+--------------+
  27. | :ref:`bool<class_bool>` | :ref:`paused<class_VideoPlayer_property_paused>` | ``false`` |
  28. +---------------------------------------+--------------------------------------------------------------------+--------------+
  29. | :ref:`VideoStream<class_VideoStream>` | :ref:`stream<class_VideoPlayer_property_stream>` | |
  30. +---------------------------------------+--------------------------------------------------------------------+--------------+
  31. | :ref:`float<class_float>` | :ref:`stream_position<class_VideoPlayer_property_stream_position>` | |
  32. +---------------------------------------+--------------------------------------------------------------------+--------------+
  33. | :ref:`float<class_float>` | :ref:`volume<class_VideoPlayer_property_volume>` | |
  34. +---------------------------------------+--------------------------------------------------------------------+--------------+
  35. | :ref:`float<class_float>` | :ref:`volume_db<class_VideoPlayer_property_volume_db>` | ``0.0`` |
  36. +---------------------------------------+--------------------------------------------------------------------+--------------+
  37. Methods
  38. -------
  39. +-------------------------------+------------------------------------------------------------------------------------------+
  40. | :ref:`String<class_String>` | :ref:`get_stream_name<class_VideoPlayer_method_get_stream_name>` **(** **)** |const| |
  41. +-------------------------------+------------------------------------------------------------------------------------------+
  42. | :ref:`Texture<class_Texture>` | :ref:`get_video_texture<class_VideoPlayer_method_get_video_texture>` **(** **)** |const| |
  43. +-------------------------------+------------------------------------------------------------------------------------------+
  44. | :ref:`bool<class_bool>` | :ref:`is_playing<class_VideoPlayer_method_is_playing>` **(** **)** |const| |
  45. +-------------------------------+------------------------------------------------------------------------------------------+
  46. | void | :ref:`play<class_VideoPlayer_method_play>` **(** **)** |
  47. +-------------------------------+------------------------------------------------------------------------------------------+
  48. | void | :ref:`stop<class_VideoPlayer_method_stop>` **(** **)** |
  49. +-------------------------------+------------------------------------------------------------------------------------------+
  50. Signals
  51. -------
  52. .. _class_VideoPlayer_signal_finished:
  53. - **finished** **(** **)**
  54. Emitted when playback is finished.
  55. Property Descriptions
  56. ---------------------
  57. .. _class_VideoPlayer_property_audio_track:
  58. - :ref:`int<class_int>` **audio_track**
  59. +-----------+------------------------+
  60. | *Default* | ``0`` |
  61. +-----------+------------------------+
  62. | *Setter* | set_audio_track(value) |
  63. +-----------+------------------------+
  64. | *Getter* | get_audio_track() |
  65. +-----------+------------------------+
  66. The embedded audio track to play.
  67. ----
  68. .. _class_VideoPlayer_property_autoplay:
  69. - :ref:`bool<class_bool>` **autoplay**
  70. +-----------+---------------------+
  71. | *Default* | ``false`` |
  72. +-----------+---------------------+
  73. | *Setter* | set_autoplay(value) |
  74. +-----------+---------------------+
  75. | *Getter* | has_autoplay() |
  76. +-----------+---------------------+
  77. If ``true``, playback starts when the scene loads.
  78. ----
  79. .. _class_VideoPlayer_property_buffering_msec:
  80. - :ref:`int<class_int>` **buffering_msec**
  81. +-----------+---------------------------+
  82. | *Default* | ``500`` |
  83. +-----------+---------------------------+
  84. | *Setter* | set_buffering_msec(value) |
  85. +-----------+---------------------------+
  86. | *Getter* | get_buffering_msec() |
  87. +-----------+---------------------------+
  88. Amount of time in milliseconds to store in buffer while playing.
  89. ----
  90. .. _class_VideoPlayer_property_bus:
  91. - :ref:`String<class_String>` **bus**
  92. +-----------+----------------+
  93. | *Default* | ``"Master"`` |
  94. +-----------+----------------+
  95. | *Setter* | set_bus(value) |
  96. +-----------+----------------+
  97. | *Getter* | get_bus() |
  98. +-----------+----------------+
  99. Audio bus to use for sound playback.
  100. ----
  101. .. _class_VideoPlayer_property_expand:
  102. - :ref:`bool<class_bool>` **expand**
  103. +-----------+-------------------+
  104. | *Default* | ``true`` |
  105. +-----------+-------------------+
  106. | *Setter* | set_expand(value) |
  107. +-----------+-------------------+
  108. | *Getter* | has_expand() |
  109. +-----------+-------------------+
  110. If ``true``, the video scales to the control size. Otherwise, the control minimum size will be automatically adjusted to match the video stream's dimensions.
  111. ----
  112. .. _class_VideoPlayer_property_paused:
  113. - :ref:`bool<class_bool>` **paused**
  114. +-----------+-------------------+
  115. | *Default* | ``false`` |
  116. +-----------+-------------------+
  117. | *Setter* | set_paused(value) |
  118. +-----------+-------------------+
  119. | *Getter* | is_paused() |
  120. +-----------+-------------------+
  121. If ``true``, the video is paused.
  122. ----
  123. .. _class_VideoPlayer_property_stream:
  124. - :ref:`VideoStream<class_VideoStream>` **stream**
  125. +----------+-------------------+
  126. | *Setter* | set_stream(value) |
  127. +----------+-------------------+
  128. | *Getter* | get_stream() |
  129. +----------+-------------------+
  130. The assigned video stream. See description for supported formats.
  131. ----
  132. .. _class_VideoPlayer_property_stream_position:
  133. - :ref:`float<class_float>` **stream_position**
  134. +----------+----------------------------+
  135. | *Setter* | set_stream_position(value) |
  136. +----------+----------------------------+
  137. | *Getter* | get_stream_position() |
  138. +----------+----------------------------+
  139. The current position of the stream, in seconds.
  140. ----
  141. .. _class_VideoPlayer_property_volume:
  142. - :ref:`float<class_float>` **volume**
  143. +----------+-------------------+
  144. | *Setter* | set_volume(value) |
  145. +----------+-------------------+
  146. | *Getter* | get_volume() |
  147. +----------+-------------------+
  148. Audio volume as a linear value.
  149. ----
  150. .. _class_VideoPlayer_property_volume_db:
  151. - :ref:`float<class_float>` **volume_db**
  152. +-----------+----------------------+
  153. | *Default* | ``0.0`` |
  154. +-----------+----------------------+
  155. | *Setter* | set_volume_db(value) |
  156. +-----------+----------------------+
  157. | *Getter* | get_volume_db() |
  158. +-----------+----------------------+
  159. Audio volume in dB.
  160. Method Descriptions
  161. -------------------
  162. .. _class_VideoPlayer_method_get_stream_name:
  163. - :ref:`String<class_String>` **get_stream_name** **(** **)** |const|
  164. Returns the video stream's name, or ``"<No Stream>"`` if no video stream is assigned.
  165. ----
  166. .. _class_VideoPlayer_method_get_video_texture:
  167. - :ref:`Texture<class_Texture>` **get_video_texture** **(** **)** |const|
  168. Returns the current frame as a :ref:`Texture<class_Texture>`.
  169. ----
  170. .. _class_VideoPlayer_method_is_playing:
  171. - :ref:`bool<class_bool>` **is_playing** **(** **)** |const|
  172. Returns ``true`` if the video is playing.
  173. **Note:** The video is still considered playing if paused during playback.
  174. ----
  175. .. _class_VideoPlayer_method_play:
  176. - void **play** **(** **)**
  177. Starts the video playback from the beginning. If the video is paused, this will not unpause the video.
  178. ----
  179. .. _class_VideoPlayer_method_stop:
  180. - void **stop** **(** **)**
  181. Stops the video playback and sets the stream position to 0.
  182. **Note:** Although the stream position will be set to 0, the first frame of the video stream won't become the current frame.
  183. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  184. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  185. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`