#region 判断鼠标在1分钟内是否移动
bool ff = true;
private void timer1_Tick_1(object sender, EventArgs e)
{
int x1 = Control.MousePosition.X;
int y1 = Control.MousePosition.Y;
if ((x == x1) && (y == y1) && ff)
{
start = DateTime.Now;
ff = false;
}
if (x != x1 || y != y1)
{
x = x1;
y = y1;
start = DateTime.Now;
ff = true;
}
this.textBox2.Text = DateTime.Now.Hour + " " + DateTime.Now.Minute + " " + DateTime.Now.Second + " " + start.Hour + " " + start.Minute + " " + start.Second;
TimeSpan ts = DateTime.Now.Subtract(start);
this.textBox1.Text = ff.ToString() + " " + ts.Hours + " " + ts.Minutes + " " + ts.Seconds;
//鼠标或键盘误动作3分钟后开始播放视频
if (ts.Minutes >= 1)
{
this.timer1.Enabled = false;
this.axWindowsMediaPlayer2.currentPlaylist.appendItem(this.axWindowsMediaPlayer2.newMedia(path + @"\VTS_01_1.avi"));
this.axWindowsMediaPlayer2.currentPlaylist.appendItem(this.axWindowsMediaPlayer2.newMedia(path + @"\录像24.avi"));
this.axWindowsMediaPlayer2.Ctlcontrols.play();
this.axWindowsMediaPlayer2.Visible = true;
this.axWindowsMediaPlayer2.settings.setMode("loop", true);
this.axWindowsMediaPlayer2.StatusChange += new EventHandler(axWindowsMediaPlayer2_StatusChange);
}
}
//正在播放、打开媒体、已停止
bool one = true;
void axWindowsMediaPlayer2_StatusChange(object sender, EventArgs e)
{
if (this.axWindowsMediaPlayer2.status == "正在播放")
{
this.axWindowsMediaPlayer2.fullScreen = true;
//单击正在播放的视频时退出视频,并重新启用计时器检查鼠标是否移动。
this.axWindowsMediaPlayer2.ClickEvent += new AxWMPLib._WMPOCXEvents_ClickEventHandler(axWindowsMediaPlayer2_ClickEvent);
}
}
void axWindowsMediaPlayer2_ClickEvent(object sender, AxWMPLib._WMPOCXEvents_ClickEvent e)
{
this.axWindowsMediaPlayer2.Ctlcontrols.stop();
this.axWindowsMediaPlayer2.Visible = false;
this.timer1.Enabled = true;
}
#endregion
版权声明:本文为博主原创文章,未经博主允许不得转载。