I have embedded a media player (axWindowsMediaPlayer) in my c# winform application. It loops and plays fine. The problem is when the form where it was located will be closed or hide. It still plays the video even the form is not active. How can I stop it when the form where it is placed is not active anymore?
Asked
Active
Viewed 1,032 times
1 Answers
2
If you want to stop the Player when the form is minimized, you can do it by
private void Form_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
//Do your stuff
}
}
Or, you want to stop the player when ever the form is not active you may try the following code
private void Form_Deactivate(object sender, EventArgs e)
{
//Do your stuff
}

γηράσκω δ' αεί πολλά διδασκόμε
- 7,172
- 2
- 21
- 35

Rama Kathare
- 920
- 9
- 29
-
I tried the form_deactivate, but when then placed this code to stop the player: "axWindowsMediaPlayer1.Ctlcontrols.stop();" But when I close the form this error pops out: "COM object that has been separated from its underlying RCW cannot be used." How can I solve this? – Lucas Juan Nov 14 '14 at 02:30