From 201a0de90faabe68f1eb701b67af30a4d11fa32b Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 7 Aug 2023 13:37:19 -0400 Subject: Public archive --- App.gd | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'App.gd') diff --git a/App.gd b/App.gd index 0cab0dd..ea1011a 100644 --- a/App.gd +++ b/App.gd @@ -5,6 +5,7 @@ extends Control # var b = "text" var audioURL +var audioFile = File.new() # Called when the node enters the scene tree for the first time. func _ready(): @@ -15,17 +16,27 @@ func _ready(): # pass func _on_PlayButton_pressed(): - print("Now playing music") - $AudioStreamPlayer.stream = load(audioURL) - $AudioStreamPlayer.play() + if !audioURL == null: + $AudioStreamPlayer.play() + print("Now playing " + audioURL) + else: + print("No music detected") + +func _on_StopButton_pressed(): + pass # Replace with function body. + func _on_BrowseButton_pressed(): print("Opening file dialog") +# $FileDialog.filters $FileDialog.popup_centered() func _on_FileDialog_file_selected(path): - print(path) - audioURL = "file://" + path + audioFile.open(path, File.READ).get_as_text().close() + $AudioStreamPlayer.stream = load(audioFile) + func _on_AudioStreamPlayer_finished(): print("Music has finished playing") + + -- cgit v1.2.3