extends Node

var music_player: AudioStreamPlayer

func _ready():
	music_player = AudioStreamPlayer.new()
	music_player.bus = "Music"
	add_child(music_player)
	music_player.process_mode = Node.PROCESS_MODE_ALWAYS
	music_player.finished.connect(_on_music_finished)

func play(stream: AudioStream):
	if music_player.stream == stream and music_player.playing:
		return  
	music_player.stream = stream
	music_player.play()

func stop():
	music_player.stop()
	
func _on_music_finished():
	music_player.play()
