Fading in/out using MediaPlayer.Volume doesn't work more than once

I’m porting a game from Mac OS X to Windows 7, and something about my fade in / out functions broke in the transition. The game is a platformer where different screens are grouped into zones, each with their own music. When the player walks into a different zone, the music from the previous zone fades out, and once the volume has reached zero, the new music fades in. This worked perfectly on Mac OS X, but now the music only fades in and out properly the first time to change zones - after that, the volume jumps from full-blast to zero with no transition. Here’s the code for them, along with the function I call to change music that uses them:

private void fadeOut(double delta)
        {
            float volume = MediaPlayer.Volume;
            volume -= (float)(delta * FADE_SPEED);
            if(volume < 0)
            {
                volume = 0;
                isFadingOut = false;
                isFadingIn = true;
                currentMusic = nextMusic;
                MediaPlayer.Stop();
                LoveGame.unloadMusic();
                LoveGame.loadMusic(currentMusic);
                MediaPlayer.Play(LoveGame.backgroundMusic);
            }
            MediaPlayer.Volume = volume;
        }

        private void fadeIn(double delta)
        {
            float volume = MediaPlayer.Volume;
            volume += (float)(delta * FADE_SPEED);
            if(volume > MAX_VOLUME)
            {
                volume = MAX_VOLUME;
                isFadingIn = false;
            }
            MediaPlayer.Volume = volume;
        }

        private void changeMusic(string newMusic)
        {
            Console.WriteLine("changeMusic(" + newMusic + ")");
            if(!nextMusic.Equals(newMusic))
            {
                nextMusic = newMusic;

                isFadingOut = true;
                isFadingIn = false;
                if(currentMusic == "silence")
                {
                    MediaPlayer.Volume = 0f;
                }
            }
        }

I’ve printed out MediaPlayer.Volume in the console, and it’s incrementing and decrementing as it should be, but the actual volume of the song is jumping from max volume to zero and back. Does anyone have any ideas why it would be doing this? Is it a bug with MediaPlayer in Windows 7, or something?

My first thought is automatic volume adjustment in windows, and or skype… Im pretty sure Ive had issues with those things, and that might account for the varience…

I thought it might be because calling MediaPlayer.Play() and/or MediaPlayer.Stop() adjusted the volume, but I’ve tried setting MediaPlayer volume back to the correct level after every call and it doesn’t make a difference.

I also tried keeping track of and modifying the volume using a separate variable that I set MediaPlayer.Volume equal to once a frame, but this doesn’t help either.

I would use SoundEffects instead, but encoding them as .xnb Song files associated with .wma audio files is the only way I’ve been able to compress them to acceptable sizes and still have MonoGame play them.

EDIT: After a little more testing it seems like MediaPlayer.Volume has no effect on the volume of songs after you’ve changed songs once - songs will always play at full blast.

Well, I just did a test of this, and I can definately adjust volume and play different music files just fine…

I think your problem sounds like you are landing on values under zero or ablove one for your volume, and thats why you get such extremes… I saw the same recently with gray-scale color values…
Part of my math dealt with ints for colors and returned numbers like 180, 200, 40 where something like 0.8f,0.9f,0.15f was needed… This resultet in ALL WHITE (max volume) colors…
There was no real problem running the code, just unintended results, and it took me a while to track down for that reason…

So be sure your volume is never set outside the range of zero to one… If no other software is interfering, I dont see much else to try… Are you SURE you are incrementing the volume by a reasonable amount?
I cant see what your values are for “delta” and “FADE_SPEED” but you could try using a temporary SAFE value, just to be sure… -And make sure nothing else is setting the volume behind your back, too… Some other class reaching in or something.

I can confirm this issue, I’ve submitted a report.
Values are fine, the Volume setter clamps them.