When media player finishes playing music in second form, it should close the second form and show h first form, but it is throwing error in first form called Display:
static void Main()
{
Application.Run(new Display());
}
Error is as follows:
This following error is thrown::::::
'System.Runtime.InteropServices.SEHException' occurred in system.windows.forms.dll.Additional information: External component has thrown an exception.at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPush
at System.Windows.ThreadContext.RunMessageLoopInner(Int32 reason,ApplicationContext context)
at System.Windows.ThreadContext.RunMessageLoop(Int32 reason,ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at <SolutionName>.Display.Main()
This is the event fired when media player finishes playing music:
private void player_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
if (e.newState == (int(WMPLib.WMPPlayState.wmppsStopped))
{
this.Close();
}
}
}
Enter your message below
Sign in or Join us (it's free).