
Publisher
cannon
MusicManager
Easily manage and control music playback in your Godot projects. It provides a convenient way to play songs, playlists, loop music, crossfade between tracks, and more. Persistent music even when changing scenes. No need for additional nodes, just use signals anywhere in your code! - Play individual songs or playlists - Loop songs or entire playlists - Crossfade between songs with adjustable crossfade time - Pause, resume, and stop music playback - Shuffle playlists - Signals for convenient in...
Music Manager
Music Manager is a powerful addon that allows you to easily manage and control music playback in your Godot projects. It provides a convenient way to play songs, playlists, loop music, crossfade between tracks, and more.
Features
- Play individual songs or playlists
- Loop songs or entire playlists
- Crossfade between songs with adjustable crossfade time
- Pause, resume, and stop music playback
- Shuffle playlists
- Signals for convenient integration with your game logic
- Persistent music even when changing scenes
- No need for nodes, just use signals anywhere in your code!
Installation
- Clone or download the repository. Or you can download an official release in the side-bar.
- Copy the
addons/MusicManager
directory into your Godot project'saddons
directory. - Enable the Music Manager addon in your Godot project by navigating to
Project > Project Settings > Plugins
and enabling the "Music Manager" plugin.
Usage
The Music Manager addon is designed to be used primarily through signals. Once enabled, it acts as a singleton, allowing you to control music playback from anywhere in your project. Even when changing scenes.
Signals
play_song(song: MusicTrack, is_looping: bool, is_fading: bool, fade_time: float)
: Play a song. Setis_looping
to loop the song,is_fading
to enable crossfading, andfade_time
to set the crossfade duration (between 0.25 and 4 seconds).play_playlist(playlist: MusicPlaylist, is_looping: bool, is_shuffling: bool, is_fading: bool, fade_time: float)
: Play a playlist. Setis_looping
to loop the playlist,is_shuffling
to shuffle the playlist order,is_fading
to enable crossfading, andfade_time
to set the crossfade duration.stop_music
: Stop all currently playing music.pause_music
: Pause all currently playing music.resume_music
: Resume paused music.
Example Usage
To create a song, simply create a new resource file that inherits MusicTrack.
Add the audio file, name, etc. in the Inspector to your new MusicTrack resource.
To create a playlist, it is essentially the same as making a song. Instead you will create a resource file that inherits MusicPlaylist.
Add your MusicTrack files in the Inspector.
And now you can play your songs or playlists from any script in your project!
# Play a song with crossfading
var song = preload("res://new_track.res")
MusicManager.play_song.emit(song, false, true, 1.0)
# Play a playlist, looping and shuffling
var playlist = preload("res://new_playlist.res")
MusicManager.play_playlist.emit(playlist, true, true, false, 0.0)
I wouldn't recommend declaring the variables this way, I would recommend using an @export var
. You can find the MusicPlayerExample in the examples directory that will show you much more use-cases of what the add-on can do.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Note: Specific licenses apply to .ogg files in the free examples. See examples/MusicPlayerExample/assets/LICENSE for details