AxWindowsMediaPlayer使用 分类: .NET ...

#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


版权声明:本文为博主原创文章,未经博主允许不得转载。

转载于:https://www.cnblogs.com/configman/archive/2012/03/31/4657594.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值