Switching MediaPlayer Songs Lowers Volume for Some Reason

I’m trying to implement music in my game, but I’m running into an issue with the MediaPlayer. For some reason, the first song I play will play at full volume, no matter how many times I play it. However, as soon as I try playing another song, the volume is significantly reduced, even though MediaPlayer.volume is still set to 1. Even if I try switching back to the original song, the volume is still reduced.

I suspect this could have something to do with how I’m handling my Song variables. At the beginning to the game, I load all of my Songs into a Dictionary in a static ResourceManager class which I then call whenever I want to play a song. Do I need to load a fresh copy of each song whenever I want to play it or something? Anyway, here’s my implementation if it helps:

public void LoadSong(String name)
ResourceManager.AddSong(name, Content.Load(name));

public static void AddSong(string name, Song song)
songs[name] = song;

public static void PlaySong(string name, bool loop = false, float volume = 1)
MediaPlayer.IsRepeating = loop;
MediaPlayer.Volume = volume;

Also, I’m using MP3 files if that makes a difference

A fresh copy would be very poor on performance and memory. For instance, ContentManager caches every asset it loads for this reason. Is the other song you’re playing lower in decibels? Which version of MonoGame are you using, and which platform are you developing for (Ex. WindowsDX, DesktopGL)?

Okay, so loading a fresh copy wouldn’t be a good solution, thanks.

The songs are using the same instruments in the same octave, so I don’t think the songs themselves are the issue.

I’m developing for Windows and I’m running my game on a Windows 10 machine. I was using I’m using MonoGame version I’ve updated to 3.7.1, but the issue still persists.

Does playing the song via SoundEffect have this issue as well?

Is this a WindowsDX project, or are you going with something like UWP?

This problem does not affect SondEffect objects at all, just Song objects. My short term solution is to just use SoundEffect objects for now, but I’d like to correct the issue eventually.

When I created the project, I just selected “Windows Project,” so I assume that means it’s DX, but I’m not sure. Is there some way to check?

Yes, that’s a WindowsDX project. This sounds like a problem with MonoGame code; can you file an issue here?

1 Like

Okay, I’ll file an issue. Thanks for the advice!

1 Like

Update: After some testing, I found that the problem seems to be related to loading SoundEffect objects. Removing all SoundEffect objects fixes the issue, while loading even a single SoundEffect using the same ContentManager I use to load the Song objects causes the issue to occur. Should I be using different ContentManager objects to load Song objects and SoundEffect objects?

The same ContentManager should work fine. Are they being loaded in raw or processed through the content pipeline (or a mix)? If they’re processed through the pipeline, which quality settings are you using (there’s a bug with Medium and Low)? If possible, can you post some of your loading code? Perhaps there’s something in there causing it to go awry.

I’m loading through the content pipeline using Best quality.

Here’s a simple example where the issue occurs. I’ve added this code to a default windows project. Pressing A or S will cause the song to play at full volume, but then pressing the other button will cause the other song to play at a reduced volume:

    Song s1, s2;
    protected override void LoadContent()
        s1 = Content.Load<Song>("exampleSong1");
        s2 = Content.Load<Song>("exampleSong2");


    protected override void Update(GameTime gameTime)
        if (Keyboard.GetState().IsKeyDown(Keys.A))
        if (Keyboard.GetState().IsKeyDown(Keys.S))

1 Like

Thanks for filing the issue! I’m mostly moving the discussion over to the issue and posted some findings. Let me know if setting MediaPlayer’s volume after playing the song helps.