Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在我的 c# winform 应用程序中嵌入了一个媒体播放器 (axWindowsMediaPlayer)。它循环播放并正常播放。问题是它所在的表单何时关闭或隐藏。即使表单未激活,它仍会播放视频。当放置它的表单不再活动时,如何停止它?
如果要在窗体最小化时停止播放器,可以通过
private void Form_Resize(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { //Do your stuff } }
或者,您想在表单未激活时停止播放器,您可以尝试以下代码
private void Form_Deactivate(object sender, EventArgs e) { //Do your stuff }