Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoPlayer: Fix reloading translation remapped stream #84794

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion doc/classes/VideoStreamPlayer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<description>
A control used for playback of [VideoStream] resources.
Supported video formats are [url=https://www.theora.org/]Ogg Theora[/url] ([code].ogv[/code], [VideoStreamTheora]) and any format exposed via a GDExtension plugin.
[b]Note:[/b] Due to a bug, VideoStreamPlayer does not support localization remapping yet.
[b]Warning:[/b] On Web, video playback [i]will[/i] perform poorly due to missing architecture-specific assembly optimizations.
</description>
<tutorials>
Expand Down
10 changes: 10 additions & 0 deletions scene/gui/video_stream_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ bool VideoStreamPlayer::has_loop() const {
void VideoStreamPlayer::set_stream(const Ref<VideoStream> &p_stream) {
stop();

// Make sure to handle stream changes seamlessly, e.g. when done via
// translation remapping.
Copy link
Member

@KoBeWi KoBeWi Nov 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this comment be below, at connect()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was meant to cover both at once, but since they're split it's not very clear yeah.

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;
Expand All @@ -248,6 +254,10 @@ void VideoStreamPlayer::set_stream(const Ref<VideoStream> &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();
Expand Down
1 change: 1 addition & 0 deletions scene/resources/video_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ Ref<VideoStreamPlayback> VideoStream::instantiate_playback() {

void VideoStream::set_file(const String &p_file) {
file = p_file;
emit_changed();
}

String VideoStream::get_file() {
Expand Down
Loading