3

I use MediaPlayer to play the background music. Sometimes, the music does not stop playing when I exit the game. This is even though I use the following code:

    protected override void OnExiting(Object sender, EventArgs args)
    {
        base.OnExiting(sender, args);

        MediaPlayer.Stop();
    }

What is wrong?

Adok
  • 31
  • 1
  • 1
    Welcome to GDSE. Have you noticed any pattern that seems to trigger the problem more or less often (how you exit the game, last action in the game, etc)? What happens if you call Stop() before onExiting(sender, args)? – Pikalek Aug 13 '19 at 15:49
  • I noticed it happens when I close the window when the opening (title) screen is shown. – Adok Aug 14 '19 at 10:23
  • Does this only appears on the title screen, and not in the rest of the game? In that case, you should look up the code of your title screen if you see something notable. – Steven Aug 19 '19 at 06:19

1 Answers1

1

As suggested in the comments, you might need to put MediaPlayer.Stop(); before base.OnExiting(sender, args);.

Vaillancourt
  • 16,325
  • 17
  • 55
  • 61