Basic Audio Player with Playlist in Godot 3.4.2

Godot banner

I am leaning Godot, not so much as a video game creator but rather an easy way to make some apps. Godot is a free game development tool and engine.

I was playing around with playing audio and came up with this. I have not found too much in the way of GUI and audio beyond games so I hope this is helpful to others. This is just a working example, not a full program. I am still learning and it will likely be a lot more involved with many changes along the way. I may post all that work too. Here is the layout:

Godot Audio Example Layout
Godot Audio Example Layout

The control script is as follows (

extends Control

# Player controls.

var audioPlayer = null
var DefaultSound = preload("res://tracks/Waves and Seagulls.wav")

func _ready():
	#get_stylebox("panel", "" ).set_texture(load("res://Assets/zenbg.png"))
	audioPlayer =
	self.add_child(audioPlayer) = DefaultSound

func _on_PlayPause_pressed():
	var button = get_node("Panel/VBoxContainer/HBoxMenu/PlayPause")
	if button.text == "Play":
		if audioPlayer.get_stream_paused() == false:
		button.text = "Pause"
		button.text = "Play"

func _on_Stop_pressed():
	if audioPlayer.get_stream_paused() == true:
	get_node("Panel/VBoxContainer/HBoxMenu/PlayPause").text = "Play"

func _on_ItemList_item_selected(index):
	var sound = get_node("Panel/VBoxContainer/ItemList").get_item_text(index)
	print("res://tracks/" + sound)
	DefaultSound = load("res://tracks/" + sound) = DefaultSound

And the ItemList script (

extends ItemList
# Collect wav files and populate listbox. I will change these to ogg
# at some point. I also want each item to be a panel with multiple audio
# tracks, icon, and desc.

func _ready():

func get_audio_resources(tracks_path):
	var base_dir =
	if == OK:
		var file_name = base_dir.get_next()
		while file_name:
			print("Found file: " + file_name)
			#if base_dir.current_is_dir():
				# If you need to capture directories
			#	continue # This doesn't work for some reason.
			if file_name.ends_with("wav"):
			file_name = base_dir.get_next()
		print("Unable to read resource path.")

If you want to download and review or run the project it is available here.