zoukankan      html  css  js  c++  java
  • 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


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

  • 相关阅读:
    AutoMapper用法
    这些基础却重要的面向对象概念,你还记得多少
    Ajax工作原理
    CSS中的绝对定位与相对定位
    NET中的Memcached.ClientLibrary使用详解
    经典Linq实例语句
    软件工程的意义
    C#.Net Mvc运营监控,计算方法/接口/action/页面执行时间
    属性与字段的区别
    SQL 递归树 子父节点相互查询
  • 原文地址:https://www.cnblogs.com/configman/p/4657594.html
Copyright © 2011-2022 走看看