From 43410ca363da329313bc9ca74882a4409335a306 Mon Sep 17 00:00:00 2001 From: Terah Date: Tue, 3 Oct 2017 23:29:30 +0200 Subject: [PATCH] Add function set_stream_position to VideoPlayer Also add docucmentation for set_stream_position in VideoPlayer --- doc/classes/VideoPlayer.xml | 9 +++++++++ scene/gui/video_player.cpp | 7 +++++++ scene/gui/video_player.h | 1 + 3 files changed, 17 insertions(+) diff --git a/doc/classes/VideoPlayer.xml b/doc/classes/VideoPlayer.xml index 57e417974e7..bac7d1e3b05 100644 --- a/doc/classes/VideoPlayer.xml +++ b/doc/classes/VideoPlayer.xml @@ -156,6 +156,15 @@ Set the video stream for this player. + + + + + + + Set the current position of the stream, in seconds. + + diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 816556af30d..190ccd50d58 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -285,6 +285,12 @@ float VideoPlayer::get_stream_position() const { return playback->get_playback_position(); }; +void VideoPlayer::set_stream_position(float p_position) { + + if (playback.is_valid()) + playback->seek(p_position); +} + Ref VideoPlayer::get_video_texture() { if (playback.is_valid()) @@ -327,6 +333,7 @@ void VideoPlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_stream_name"), &VideoPlayer::get_stream_name); + ClassDB::bind_method(D_METHOD("set_stream_position", "position"), &VideoPlayer::set_stream_position); ClassDB::bind_method(D_METHOD("get_stream_position"), &VideoPlayer::get_stream_position); ClassDB::bind_method(D_METHOD("set_autoplay", "enabled"), &VideoPlayer::set_autoplay); diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h index bea10907bb6..f04e90365f9 100644 --- a/scene/gui/video_player.h +++ b/scene/gui/video_player.h @@ -93,6 +93,7 @@ public: String get_stream_name() const; float get_stream_position() const; + void set_stream_position(float p_position); void set_autoplay(bool p_enable); bool has_autoplay() const;