I am recreating pokemon platinum for pc and I want to load background music files.
I never worked a lot with audio in monogame.
Can someone explain how
SoundBank and
SongCollection
work?
I could not get any good information from the documentation
SoundBank appears to be deprecated
// Create a song instance
Song song = Content.Load("Content\\Audio\\MySong");
// Create a song collection instance
SongCollection songCollection = new SongCollection();
// Add the song to the collection
songCollection.Add(song);
To play a song from the song collection, you need to use
the MediaPlayer class, which provides static methods and
properties for controlling the playback. For example:
// Play the song collection
MediaPlayer.Play(songCollection);
// Pause the playback
MediaPlayer.Pause();
// Resume the playback
MediaPlayer.Resume();
// Stop the playback
MediaPlayer.Stop();
// Get or set the volume
MediaPlayer.Volume = 0.5f;
// Get or set the position
MediaPlayer.PlayPosition = TimeSpan.FromSeconds(10);
// Get or set the repeat mode
MediaPlayer.IsRepeating = true;
This should help ypu get started with SongCollection.
1 Like