Unlike something like the AnimationPlayer, I can’t queue multiple AudioStreams on a AudioStreamPlayer so they play perfectly one after the other. My music composer is looking a way to play a piece of music that serves as an entry into the second piece of music which is a loop. How do I go about realizing this?
For now your only option is to manually play the new audio when the last one finishes. You could use the AudioStreamPlayer.finished signal to play the next one.
Ah dang, that looks great indeed! I’m not able to go into any dev or alpha versions because I’m making a game that’s set to release this year, but I’ll make the switch when able.
My music composer actually found another solution just now!! In the import settings of the AudioStream (the audio clip) you can enter a ‘loop begin’ and when you set loop to true, it’ll still play the clip from the very start – and start looping once it’s inside the loop area. Thumbs up!!
extends Node
@onready var audio_stream_player: AudioStreamPlayer = $AudioStreamPlayer2
@onready var h_box_container: HBoxContainer = $HBoxContainer
func _ready() -> void:
audio_stream_player.play()
var audio_stream = audio_stream_player.stream as AudioStreamInteractive
var playback = audio_stream_player.get_stream_playback() as AudioStreamPlaybackInteractive
for i in audio_stream.clip_count:
var clip_name = audio_stream.get_clip_name(i)
var button = Button.new()
button.text = clip_name
h_box_container.add_child(button)
button.pressed.connect(func(): playback.switch_to_clip_by_name(clip_name))