Get all sound components in group?

Is there an API to get all sound components in a group? My use case is I want to stop all sounds in a particular sound group, and currently I’m doing something like this:

local music_files = {
		"music_game_over1",
		"music_game_over2",
		"music_entrance2",
		"music_home_menu",
		"music_main"
	}
	
	for key, value in pairs(music_files) do
		local component = "/sound_controller#" .. value
		msg.post(component, "stop_sound")
	end

Is there a better way to loop over all the sound components in a sound group without having to manually define them like I’m doing above?

Thanks!

No. But my suggestion would be to have a sound manager script that keeps track of what’s currently played and only stop that sound.

1 Like