extends AudioStreamPlayer

class_name RandomAudioStreamPlayer

@export var audio_collections := [] as Array[AudioStreamCollection]

func play_random():
	if audio_collections == null:
		push_error("empty audio_collections")
		return
	var audio_collection:=audio_collections.pick_random() as AudioStreamCollection
	stream = audio_collection.audios.pick_random()
	if stream == null:
		push_error("empty stream in audio_collection", audio_collection)
		return
	pitch_scale = randf_range(.8, 1)
	play()
