Example #1
0
        /// <summary>
        /// 这是保存上次播放进度
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="currentPosition"></param>
        public void SavSavePlayFileName(string fileName, double currentPosition)
        {
            CurrentPlay PlayFile = new CurrentPlay
            {
                FileName        = fileName,
                CurrentPosition = currentPosition
            };

            FileHelper.SaveFileAsJson(PlayFile, "CurrentPlay.json", "");
        }
Example #2
0
        //加载最新播放列表
        private void LoadList()
        {
            if (playerCore.LoadNewList())
            {
                //【1】显示播放列表
                this.lbVideoList.Items.AddRange(this.playerCore.FileList.Keys.ToArray());

                //【2】读取上次播放的位置并自动播放

                string playFileName = this.playerCore.ReadPlayFileName();

                CurrentPlay currentPlay = this.playerCore.ReadPlayFile();

                #region 旧方法
                //int index = this.playerCore.ReadPlayIndex();

                //if (index > this.lbVideoList.Items.Count - 1 || index == -1)//如果保存的播放记录所对应的文件被删除或文件丢失
                //{
                //    this.lbVideoList.SelectedIndex = 0;
                //}
                //else
                //{
                //    this.lbVideoList.SelectedIndex = index;
                //}
                #endregion

                if (currentPlay.FileName.Trim().Length == 0)//如果保存的播放记录所对应的文件被删除或文件丢失
                {
                    this.lbVideoList.SelectedIndex = 0;
                }
                else
                {
                    this.lbVideoList.SelectedItem = currentPlay.FileName;
                    //设置上次播放时长
                    this.myPlayer.Ctlcontrols.currentPosition = currentPlay.CurrentPosition;
                }

                //开启播放
                lbVideoList_SelectedIndexChanged(null, null);


                //【3】开启按钮
                this.btnPause_Start.Enabled = true;
                this.btnNext.Enabled        = true;
                this.btnPre.Enabled         = true;
                this.llblSaveAs.Enabled     = true;
                this.llblClear.Enabled      = true;
            }
        }