Media Player keeps playing when form is closed in MonoGame.Forms (*SOLVED*)

Hello,

Using Visual Studio 2022 C# with MonoGame.Forms 3.8.1.303

I am using the MediaPalayer to play music in a form. When the form is closed the music keeps playing until the main form is closed. Searching the Internet, I found that the function below is the way to do it.

protected override void OnExiting(object sender, EventArgs args)
        {
            MediaPlayer.Stop();
            base.OnExiting(sender, args);
        }

The problem is that OnExiting is not available in MonoGame.Forms. What is the correct way to close the media player when closing a form with MonoGame.Forms?

Thank you,

You need to add MonoGame.Forms to your help request title… or the tag…

You need to add MonoGame.Forms to your help request title

Done.

I finally got if figured out.

Go to the form properties and go to the events. Click on FormClosed event. From there just add the code to make the player stop, upon form exit.
private void AboutForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            DrawTest.exitApp();
        }
public static void exitApp()
        {
            MediaPlayer.Stop(); 
        }