diff options
author | Yuri Sizov <yuris@humnom.net> | 2023-07-12 17:14:44 +0200 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-07-12 17:14:44 +0200 |
commit | 1978b7c717160effaf1fcb4b0e49c69a27124a9e (patch) | |
tree | 9ff169d382577ed35edf962c0bfda216becdee23 | |
parent | 216aa450a69ccece4e509f490200660954db23a0 (diff) | |
parent | e3da9176a0b51459126469718fa19502655a3493 (diff) | |
download | redot-engine-1978b7c717160effaf1fcb4b0e49c69a27124a9e.tar.gz |
Merge pull request #77858 from kinami-imai/expose_videostreamplayer_video_length
Expose VideoStreamPlayer video length
-rw-r--r-- | doc/classes/VideoStreamPlayer.xml | 7 | ||||
-rw-r--r-- | scene/gui/video_stream_player.cpp | 8 | ||||
-rw-r--r-- | scene/gui/video_stream_player.h | 1 |
3 files changed, 16 insertions, 0 deletions
diff --git a/doc/classes/VideoStreamPlayer.xml b/doc/classes/VideoStreamPlayer.xml index 2c149a9bbf..19b1e20e5b 100644 --- a/doc/classes/VideoStreamPlayer.xml +++ b/doc/classes/VideoStreamPlayer.xml @@ -12,6 +12,13 @@ <tutorials> </tutorials> <methods> + <method name="get_stream_length" qualifiers="const"> + <return type="float" /> + <description> + The length of the current stream, in seconds. + [b]Note:[/b] For [VideoStreamTheora] streams (the built-in format supported by Godot), this value will always be zero, as getting the stream length is not implemented yet. The feature may be supported by video formats implemented by a GDExtension add-on. + </description> + </method> <method name="get_stream_name" qualifiers="const"> <return type="String" /> <description> diff --git a/scene/gui/video_stream_player.cpp b/scene/gui/video_stream_player.cpp index 07009ff976..49a24f217d 100644 --- a/scene/gui/video_stream_player.cpp +++ b/scene/gui/video_stream_player.cpp @@ -401,6 +401,13 @@ String VideoStreamPlayer::get_stream_name() const { return stream->get_name(); } +double VideoStreamPlayer::get_stream_length() const { + if (playback.is_null()) { + return 0; + } + return playback->get_length(); +} + double VideoStreamPlayer::get_stream_position() const { if (playback.is_null()) { return 0; @@ -486,6 +493,7 @@ void VideoStreamPlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_audio_track"), &VideoStreamPlayer::get_audio_track); ClassDB::bind_method(D_METHOD("get_stream_name"), &VideoStreamPlayer::get_stream_name); + ClassDB::bind_method(D_METHOD("get_stream_length"), &VideoStreamPlayer::get_stream_length); ClassDB::bind_method(D_METHOD("set_stream_position", "position"), &VideoStreamPlayer::set_stream_position); ClassDB::bind_method(D_METHOD("get_stream_position"), &VideoStreamPlayer::get_stream_position); diff --git a/scene/gui/video_stream_player.h b/scene/gui/video_stream_player.h index 14faab3ec1..7a922b2d92 100644 --- a/scene/gui/video_stream_player.h +++ b/scene/gui/video_stream_player.h @@ -108,6 +108,7 @@ public: float get_volume_db() const; String get_stream_name() const; + double get_stream_length() const; double get_stream_position() const; void set_stream_position(double p_position); |