From 5242b96f64e7d5e1520309475b3d973cfcbafed5 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Sun, 8 Dec 2024 03:54:15 +0200 Subject: [PATCH] Fix audio not playing at the appropriate position --- src/UI/Timeline/LayerButton.gd | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/UI/Timeline/LayerButton.gd b/src/UI/Timeline/LayerButton.gd index 4163eb82b..91ac1e78a 100644 --- a/src/UI/Timeline/LayerButton.gd +++ b/src/UI/Timeline/LayerButton.gd @@ -86,9 +86,11 @@ func _play_audio() -> void: if not is_instance_valid(audio_player): return var audio_length := audio_player.stream.get_length() - var normalized_pos := Global.current_project.current_frame / Global.current_project.fps - if normalized_pos < 1: - audio_player.play(normalized_pos * audio_length) + var final_frame := audio_length * Global.current_project.fps + if Global.current_project.current_frame < final_frame: + var inverse_fps := 1.0 / Global.current_project.fps + var playback_position := Global.current_project.current_frame * inverse_fps + audio_player.play(playback_position) else: audio_player.stop()