diff --git a/doc/classes/VideoStreamPlayer.xml b/doc/classes/VideoStreamPlayer.xml
index 2c149a9bbfa..19b1e20e5ba 100644
--- a/doc/classes/VideoStreamPlayer.xml
+++ b/doc/classes/VideoStreamPlayer.xml
@@ -12,6 +12,13 @@
+
+
+
+ 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.
+
+
diff --git a/scene/gui/video_stream_player.cpp b/scene/gui/video_stream_player.cpp
index 07009ff9762..49a24f217dc 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 14faab3ec17..7a922b2d924 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);