Skip to main content

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_AudioSettings as your Game Instance,
      • or set your Game Instance to inherit from it,
      • or implement the BPI_GameInstanceAudio interface 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.

Call these functions to Play, Stop, and Queue music tracks.

Music Functions

Function Reference

PlayTrack

Purpose: Play a single track immediately.
Inputs:

  • Track (Cue)SoftObject<SoundBase>
  • FadeInfloat (optional fade-in time)
  • Volumefloat (0–1, optional)
Play Track

StartPlaylist

Purpose: Begin playback of the current playlist.
Inputs:

  • Shufflebool (randomize order)
Start Playlist

StopMusic

Purpose: Stop current music.
Inputs:

  • FadeOutfloat (fade-out time in seconds)
    Notes: Safe to call even if nothing is playing.
Stop Music

AddTrackToPlaylist

Purpose: Append a track to the active playlist.
Inputs:

  • TrackSoftObject<SoundBase>
    Notes: No effect if the same asset already exists in the playlist.
Add track to playlist

RemoveTrackFromPlaylist

Purpose: Remove a track from the active playlist.
Inputs (choose one):

  • TrackSoftObject<SoundBase>
    Notes: If the removed track is currently playing, it will continue until finished.
Remove track from playlist

PlayNextTrack

Purpose: Advance to the next track in the active playlist.
Inputs:

  • Shufflebool (if true, plays a random track; otherwise plays next or loops)
Play next track

SetNewPlaylist

Purpose: Replace the current playlist with a new list.
Inputs:

  • SoundBaseArray<SoftObject<SoundBase>>
  • StartPlayingbool (start immediately; if false and something is playing, the new list will start after)
  • Shufflebool (play in order or shuffle)
Set new playlist
Use Fades For smooth transitions