> For the complete documentation index, see [llms.txt](https://docs.msquared.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.msquared.io/creation/unreal-development/features-and-tutorials/audio-and-sounds/audio-systems/music-controller.md).

# Music Controller

The Music Controller is a tool for playing music in your world, and for directly controlling it with a Control Panel.

### How to Use the Music Controller

1. Add an instance of `BPM_M2_Audio_MusicController` to your level.
2. Import your music assets and ensure that they **ALL** have their `Virtualization Mode` parameter set to `Play when Silent`.\\

   <figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-e2338940da2ef9ee9760cf9d51a213b485cc908c%2F02c0bb4f-e460-4ffb-9b84-f4f3443fa338.png?alt=media" alt="" width="391"><figcaption></figcaption></figure>
3. Set the SoundClass of your music assets to `SCL_M2_NonWorld_Music`.
4. Create a DataTable, using `S_M2_Audio_MusicData` as the Structure, and add your music tracks, giving each a unique name.\\
5. Add the DataTable to your MusicController in the `Music Data Table` field, this can be found under `Config` on the selected BP's `Details` panel, as seen below. You can now either set the system to automatically load your music at game start, and begin playing, or be manually controlled.\\

   <figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-a0aedbf2f7232dcc35d63e65852de03585af04ce%2Fimage.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

   \
   Enabling `Auto Play at Game Start` will load your music tracks and play them in the chosen mode (List being the default).
6. Once in-game, the panel can be opened as a Director by clicking on the actor, or adding the ActorTag `AutoOpen`, and used as follows:\\

   <figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-4b688bab1a8d7dbff0e5e549995473069c59795f%2Fimage.png?alt=media" alt="" width="279"><figcaption></figcaption></figure>

   * Currently Playing: This shows the currently-playing track, and the state, such as “Playing” or “Paused”. Beneath this, the time remaining on the current track is displayed.
   * Playlist: This will show a list of buttons for the loaded data table of music. In the above track, the Playlist is empty, as nothing has been loaded. The buttons can be clicked to immediately being playing the clicked track.
   * Playlist Mode:
     * Queue: Each track is “consumed” once played. This functions like Spotify’s Queue.
     * List: Each track plays in sequence, and once the playlist finishes, it loops back to the start.
     * Random Playlist: Tracks are played randomly from the playlist.
   * Play/Stop/Skip: begins playing the Playlist, stops it, or skips the current track.
   * Pause: Pauses the currently-playing track.
   * Looping: Loops the current track.
   * Available Tracks: Shows a drop-down of all tracks found in the DataTable.
   * Track List Controls: Allows addition and removal of tracks to/from the Playlist.
   * Preview: Plays the track that is selected in Available Tracks (only the Control Panel user will hear this).
   * Volume: Adjusts the current volume. In preview mode, this will only affect the music that is being previewed.
