Music & Playlist
Lightweight music manager for UE5 that supports single-track play and playlist control. Designed to persist music across level loads.
Structure of the Music Playing Functionality
- GI_AudioSettings
- We use the Game Instance as it persists between level loads. By creating the Audio Components on it, they persist across loads.
- Either use
GI_AudioSettingsas your Game Instance,- or set your Game Instance to inherit from it,
- or implement the
BPI_GameInstanceAudiointerface in your Game Instance class and add logic for its functions.
- BFL_Music
- We use a Blueprint Function Library to call music player functions.
- This makes it simple to call the functions from anywhere,
- removes the need to get a reference to the Game Instance each time,
- and places all logic in a single place we can change later without breaking callers.
- We use a Blueprint Function Library to call music player functions.
Call these functions to Play, Stop, and Queue music tracks.
Function Reference
PlayTrack
Purpose: Play a single track immediately.
Inputs:
Track (Cue)—SoftObject<SoundBase>FadeIn—float(optional fade-in time)Volume—float(0–1, optional)
StartPlaylist
Purpose: Begin playback of the current playlist.
Inputs:
Shuffle—bool(randomize order)
StopMusic
Purpose: Stop current music.
Inputs:
FadeOut—float(fade-out time in seconds)
Notes: Safe to call even if nothing is playing.
AddTrackToPlaylist
Purpose: Append a track to the active playlist.
Inputs:
Track—SoftObject<SoundBase>
Notes: No effect if the same asset already exists in the playlist.
RemoveTrackFromPlaylist
Purpose: Remove a track from the active playlist.
Inputs (choose one):
Track—SoftObject<SoundBase>
Notes: If the removed track is currently playing, it will continue until finished.
PlayNextTrack
Purpose: Advance to the next track in the active playlist.
Inputs:
Shuffle—bool(if true, plays a random track; otherwise plays next or loops)
SetNewPlaylist
Purpose: Replace the current playlist with a new list.
Inputs:
SoundBase—Array<SoftObject<SoundBase>>StartPlaying—bool(start immediately; if false and something is playing, the new list will start after)Shuffle—bool(play in order or shuffle)
Use Fades For smooth transitions