Esempio n. 1
0
        /// <summary>
        /// 主计时器,每50ms自动根据播放器的状态来控制播放器的动作和重绘视图
        /// </summary>>
        private void time_Tick(Object sender, EventArgs e)
        {
            //获取player状态
            Constant.PLAY_STATE state = (Constant.PLAY_STATE) this.player.GetState();
            switch (state)
            {
            case Constant.PLAY_STATE.PS_PLAY:
            case Constant.PLAY_STATE.PS_PAUSED:     //暂停状态
                this.position = this.player.GetPosition();
                this.duration = this.player.GetDuration();
                //设置视频进度条值
                this.pgb_time.DM_Value = this.position / Convert.ToDouble(this.duration) * 100.0;
                if (position > 7000 && position / 1000 % 7 == 0)
                {
                    int time = Convert.ToInt32((position / 1000 / 7));
                    if (captionDic.ContainsKey(time))
                    {
                        //player.SetConfig(511, time + " \r\n" + "00:00:" + time * 7 + ",500" + " --> 00:00:" + (time + 1) * 7 + ",000" + " \r\n" + captionDic[time]);
                        label2.Text = captionDic[time];
                        //Console.WriteLine(time + " \r\n" + "00:00:" + time * 7 + ",500" + " --> 00:00:" + (time + 1) * 7 + ",000" + " \r\n" + captionDic[time]);
                    }
                    else
                    {
                        label2.Text = "";
                    }
                    //isTest = true;
                }
                //    CaptionThread.position = Convert.ToInt32(position);
                //设置 当前播放时间/视频总共时间
                this.lb_time.Text = PlayHelper.GetTime(this.position) + " / " + PlayHelper.GetTime(this.duration);
                this.pgb_time.Invalidate();
                UpdateVol();
                break;
            }

            if (this.Full)
            {
                if ((this.LastCursorX == Cursor.Position.X) && (this.LastCursorY == Cursor.Position.Y))
                {
                    this.CursorStayTime++;
                }
                else
                {
                    this.CursorStayTime = 0;
                }
                if (Cursor.Position.Y >= (Screen.PrimaryScreen.Bounds.Height - this.menuPanel.Height))
                {
                    this.menuPanel.BringToFront();
                }
                else if (this.CursorStayTime >= this.CursorStayMaxTime)
                {
                    this.player.BringToFront();
                }
                this.LastCursorX = Cursor.Position.X;
                this.LastCursorY = Cursor.Position.Y;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 主计时器,每50ms自动根据播放器的状态来控制播放器的动作和重绘视图
        /// </summary>>
        private void time_Tick(Object sender, EventArgs e)
        {
            //获取player状态
            Constant.PLAY_STATE state = (Constant.PLAY_STATE) this.player.GetState();
            switch (state)
            {
            case Constant.PLAY_STATE.PS_PLAY:
            case Constant.PLAY_STATE.PS_PAUSED:     //暂停状态
                this.position = this.player.GetPosition();
                this.duration = this.player.GetDuration();
                //设置视频进度条值
                this.pgb_time.DM_Value = this.position / Convert.ToDouble(this.duration) * 100.0;
                //设置 当前播放时间/视频总共时间
                this.lb_time.Text = PlayHelper.GetTime(this.position) + " / " + PlayHelper.GetTime(this.duration);
                this.pgb_time.Invalidate();
                UpdateVol();
                break;
            }

            if (this.Full)
            {
                if ((this.LastCursorX == Cursor.Position.X) && (this.LastCursorY == Cursor.Position.Y))
                {
                    this.CursorStayTime++;
                }
                else
                {
                    this.CursorStayTime = 0;
                }
                if (Cursor.Position.Y >= (Screen.PrimaryScreen.Bounds.Height - this.menuPanel.Height))
                {
                    this.menuPanel.BringToFront();
                }
                else if (this.CursorStayTime >= this.CursorStayMaxTime)
                {
                    this.player.BringToFront();
                }
                this.LastCursorX = Cursor.Position.X;
                this.LastCursorY = Cursor.Position.Y;
            }
        }