mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Stop audio from playing when looping, and the audio does not play at the first frame
This commit is contained in:
parent
fa3642f99c
commit
019a8db21c
|
@ -1,7 +1,14 @@
|
|||
extends Panel
|
||||
|
||||
## Emitted when the animation starts playing.
|
||||
signal animation_started(forward: bool)
|
||||
## Emitted when the animation reaches the final frame and is not looping,
|
||||
## or if the animation is manually paused.
|
||||
## Note: This signal is not emitted if the animation is looping.
|
||||
signal animation_finished
|
||||
## Emitted when the animation loops, meaning when it reaches the final frame
|
||||
## and the animation keeps playing.
|
||||
signal animation_looped
|
||||
|
||||
enum LoopType { NO, CYCLE, PINGPONG }
|
||||
|
||||
|
@ -688,9 +695,11 @@ func _on_AnimationTimer_timeout() -> void:
|
|||
animation_timer.wait_time = (
|
||||
project.frames[project.current_frame].duration * (1 / fps)
|
||||
)
|
||||
animation_looped.emit()
|
||||
animation_timer.start()
|
||||
LoopType.PINGPONG:
|
||||
animation_forward = false
|
||||
animation_looped.emit()
|
||||
_on_AnimationTimer_timeout()
|
||||
|
||||
else:
|
||||
|
@ -713,9 +722,11 @@ func _on_AnimationTimer_timeout() -> void:
|
|||
animation_timer.wait_time = (
|
||||
project.frames[project.current_frame].duration * (1 / fps)
|
||||
)
|
||||
animation_looped.emit()
|
||||
animation_timer.start()
|
||||
LoopType.PINGPONG:
|
||||
animation_forward = true
|
||||
animation_looped.emit()
|
||||
_on_AnimationTimer_timeout()
|
||||
frame_scroll_container.ensure_control_visible(
|
||||
Global.frame_hbox.get_child(project.current_frame)
|
||||
|
|
|
@ -47,6 +47,7 @@ func _ready() -> void:
|
|||
layer.audio_changed.connect(func(): audio_player.stream = layer.audio)
|
||||
add_child(audio_player)
|
||||
Global.animation_timeline.animation_started.connect(_on_animation_started)
|
||||
Global.animation_timeline.animation_looped.connect(_on_animation_looped)
|
||||
Global.animation_timeline.animation_finished.connect(_on_animation_finished)
|
||||
custom_minimum_size.y = Global.animation_timeline.cel_size
|
||||
label.text = layer.name
|
||||
|
@ -78,6 +79,14 @@ func _on_animation_started(_dir: bool) -> void:
|
|||
_play_audio()
|
||||
|
||||
|
||||
func _on_animation_looped() -> void:
|
||||
var layer := Global.current_project.layers[layer_index]
|
||||
if layer is AudioLayer:
|
||||
if layer.playback_frame != 0:
|
||||
if is_instance_valid(audio_player):
|
||||
audio_player.stop()
|
||||
|
||||
|
||||
func _on_animation_finished() -> void:
|
||||
animation_running = false
|
||||
if is_instance_valid(audio_player):
|
||||
|
|
Loading…
Reference in a new issue