1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Load ogg audio files

This commit is contained in:
Emmanouil Papadeas 2024-12-08 00:23:38 +02:00
parent cc0ab5949f
commit 1b7494a767
2 changed files with 17 additions and 0 deletions

View file

@ -45,6 +45,8 @@ func handle_loading_file(file: String) -> void:
return
var file_name: String = file.get_file().get_basename()
Global.control.find_child("ShaderEffect").change_shader(shader, file_name)
elif file_ext == "ogg": # Audio file
open_audio_file(file)
else: # Image files
# Attempt to load as APNG.
@ -902,6 +904,20 @@ func set_new_imported_tab(project: Project, path: String) -> void:
Global.tabs.delete_tab(prev_project_pos)
func open_audio_file(path: String) -> void:
var audio_stream := AudioStreamOggVorbis.load_from_file(path)
if not is_instance_valid(audio_stream):
return
var project := Global.current_project
for layer in project.layers:
if layer is AudioLayer and not is_instance_valid(layer.audio):
layer.audio = audio_stream
return
var new_layer := AudioLayer.new(project)
new_layer.audio = audio_stream
Global.animation_timeline.add_layer(new_layer, project)
func update_autosave() -> void:
if not is_instance_valid(autosave_timer):
return

View file

@ -43,6 +43,7 @@ func _ready() -> void:
elif layer is AudioLayer:
audio_player = AudioStreamPlayer.new()
audio_player.stream = layer.audio
layer.audio_changed.connect(func(): audio_player.stream = layer.audio)
add_child(audio_player)
custom_minimum_size.y = Global.animation_timeline.cel_size
label.text = layer.name