class_videoplayer.rst 11 KB

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