mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-30 23:19:49 +00:00
Fix crashes when the audio layer has no track
This commit is contained in:
parent
16c06bf9af
commit
04f5a162c0
|
@ -537,7 +537,7 @@ func export_video(export_paths: PackedStringArray, project: Project) -> bool:
|
|||
var max_audio_duration := 0
|
||||
var adelay_string := ""
|
||||
for layer in project.layers:
|
||||
if layer is AudioLayer and layer.audio is AudioStreamMP3:
|
||||
if layer is AudioLayer and is_instance_valid(layer.audio) and layer.audio is AudioStreamMP3:
|
||||
var temp_file_name := str(audio_layer_count + 1).pad_zeros(number_of_digits) + ".mp3"
|
||||
var temp_file_path := temp_path_real.path_join(temp_file_name)
|
||||
var temp_audio_file := FileAccess.open(temp_file_path, FileAccess.WRITE)
|
||||
|
@ -550,8 +550,8 @@ func export_video(export_paths: PackedStringArray, project: Project) -> bool:
|
|||
"[%s]adelay=%s:all=1[%sa];" % [audio_layer_count, delay, audio_layer_count]
|
||||
)
|
||||
audio_layer_count += 1
|
||||
if layer.audio.get_length() >= max_audio_duration:
|
||||
max_audio_duration = layer.audio.get_length()
|
||||
if layer.get_audio_length() >= max_audio_duration:
|
||||
max_audio_duration = layer.get_audio_length()
|
||||
if audio_layer_count > 0:
|
||||
# If we have audio layers, merge them all into one file.
|
||||
for i in audio_layer_count:
|
||||
|
|
|
@ -19,6 +19,13 @@ func _init(_project: Project, _name := "") -> void:
|
|||
name = _name
|
||||
|
||||
|
||||
func get_audio_length() -> float:
|
||||
if is_instance_valid(audio):
|
||||
return audio.get_length()
|
||||
else:
|
||||
return -1.0
|
||||
|
||||
|
||||
# Overridden Methods:
|
||||
func serialize() -> Dictionary:
|
||||
var data := {"name": name, "type": get_layer_type()}
|
||||
|
|
|
@ -406,7 +406,7 @@ func _sort_cel_indices_by_frame(a: Array, b: Array) -> bool:
|
|||
func _is_playing_audio() -> void:
|
||||
var frame_class := Global.current_project.frames[frame]
|
||||
var layer_class := Global.current_project.layers[layer] as AudioLayer
|
||||
var audio_length := layer_class.audio.get_length()
|
||||
var audio_length := layer_class.get_audio_length()
|
||||
var frame_pos := frame_class.position_in_seconds(
|
||||
Global.current_project, layer_class.playback_frame
|
||||
)
|
||||
|
|
|
@ -90,7 +90,7 @@ func _play_audio() -> void:
|
|||
var layer := Global.current_project.layers[layer_index] as AudioLayer
|
||||
if not layer.visible:
|
||||
return
|
||||
var audio_length := audio_player.stream.get_length()
|
||||
var audio_length := layer.get_audio_length()
|
||||
var frame := Global.current_project.frames[Global.current_project.current_frame]
|
||||
var frame_pos := frame.position_in_seconds(Global.current_project, layer.playback_frame)
|
||||
if frame_pos >= 0 and frame_pos < audio_length:
|
||||
|
|
Loading…
Reference in a new issue