From 7d0c561e02d37a27884162128387064f4fb1b90b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sun, 12 Nov 2023 15:22:04 +0100 Subject: VideoPlayer: Fix reloading translation remapped stream Fixes #43917. --- scene/gui/video_stream_player.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'scene/gui') diff --git a/scene/gui/video_stream_player.cpp b/scene/gui/video_stream_player.cpp index ac09844128..41a210e180 100644 --- a/scene/gui/video_stream_player.cpp +++ b/scene/gui/video_stream_player.cpp @@ -237,6 +237,12 @@ bool VideoStreamPlayer::has_loop() const { void VideoStreamPlayer::set_stream(const Ref &p_stream) { stop(); + // Make sure to handle stream changes seamlessly, e.g. when done via + // translation remapping. + if (stream.is_valid()) { + stream->disconnect_changed(callable_mp(this, &VideoStreamPlayer::set_stream)); + } + AudioServer::get_singleton()->lock(); mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size()); stream = p_stream; @@ -248,6 +254,10 @@ void VideoStreamPlayer::set_stream(const Ref &p_stream) { } AudioServer::get_singleton()->unlock(); + if (stream.is_valid()) { + stream->connect_changed(callable_mp(this, &VideoStreamPlayer::set_stream).bind(stream)); + } + if (!playback.is_null()) { playback->set_paused(paused); texture = playback->get_texture(); -- cgit v1.2.3