• AxWindowsMediaPlayer使用 分类: .NET 20120331 12:50 1644人阅读 评论(0) 收藏


    #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


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

  • 相关阅读:
    Linux学习32
    Linux学习31-如何查看 linux 系统是centos还是ubuntu,并查看系统版本号
    python测试开发django-124.bootstrap点删除按钮弹确认删除
    python测试开发django-123.bootstrap模态框(modal)垂直居中显示
    python测试开发django-122.bootstrap模态框(modal)学习
    Linux下查询tomcat进程命令
    linux服务器通过X11实现图形化界面显示 1 背景描述
    linux(centos)配置ipv6网卡
    linux 下给网卡添加ipv6、路由
    2021年最新大厂php+go面试题集(1)
  • 原文地址:https://www.cnblogs.com/configman/p/4657594.html
Copyright © 2020-2023  润新知