I am trying to get random music to play on my app, when the user runs the program, a random music will play and when it finishes, it will choose another random music, with this code:
extends StreamPlayer
const tracks = [
'music_one',
'music_two',
'music_three',
'music_four'
]
func _ready():
var rand_nb = Randi() % tracks.size()
var audiostream = load('res://music/' + tracks[rand_nb] + '.ogg')
set_stream(audiostream)
play()
pass
Only the first music in the list music_one
plays and when it finishes, no other music plays, I also want music to keep playing even when the user changes scene but I don't know how to do that