Beispiel #1
0
 public static bool isRightExt(VideoItem item)
 {
     string[] strArray = new string[] { ".avi", ".mp4", ".rm", ".mkv", ".wmv", ".rmvb", ".flv", ".mov", ".mpg", ".divx", ".xvid" };
     foreach (string str in strArray)
     {
         if (item.Ext.ToLower() == str)
         {
             return true;
         }
     }
     return false;
 }
Beispiel #2
0
 //打开一个文件
 public static VideoItem OpenFile()
 {
     OpenFileDialog dialog = new OpenFileDialog
     {
         Filter = "媒体文件|*.mp4;*.avi;*.rm;*.rmvb;*.flv;*.mkv;*.wmv;|所有文件|*.*"
     };
     if (dialog.ShowDialog() == DialogResult.OK)
     {
         VideoItem newVideo = new VideoItem(dialog.SafeFileName, dialog.FileName);
         if (PlayHelper.isRightExt(newVideo)) return newVideo;
     }
     return null;
 }
Beispiel #3
0
        private void playListGrid_rightItemClick(object sender, EventArgs e)
        {
            MouseEventArgs mouse_e= (MouseEventArgs)e;
            if (mouse_e.Button == MouseButtons.Right)
            {
                Item clickedItem = (Item)sender;
                foreach (var item in this.videoList)
                {
                    if (item.Name == clickedItem.Text)
                    {
                        Console.WriteLine(clickedItem.Text);
                        this.currItem = item;
                        if(clickedItem.OnLine == true)
                        {
                        this.currItem.IsPlaying = true;
                    }
                        break;
                    }
                }

                var x = this.PointToClient(Control.MousePosition).X;
                var y = this.PointToClient(Control.MousePosition).Y - 40;
                this.删除当前项ToolStripMenuItem.Enabled = true;
                this.metroContextMenu2.Show(player, new Point(x, y));
            }
        }
Beispiel #4
0
        /// <summary>
        /// 点击当前播放列表的视频, 并切换到该视频
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void playListGrid_ItemClick(object sender, EventArgs e)
        {
            Console.WriteLine("click");
            Item clickedItem = (Item)sender;

            foreach (var item in this.videoList)
            {
                if (item.Name == clickedItem.Text)
                {
                    Console.WriteLine(clickedItem.Text);
                    this.playingItem = item;
                    item.IsPlaying = true;
                }
                else
                {
                    item.IsPlaying = false;
                }
            }
            this.InitPlayListView(playingItem);
            this.player.Open(playingItem.Url);
            this.CloseTwoPlay();
            Btnplay.DM_Key = DMSkin.Controls.DMLabelKey.暂停;
            this.player.Focus();
        }
Beispiel #5
0
        private void OpenAndPlay()
        {
            VideoItem item = PlayOp.OpenFile();
            if (item == null) return;
            item.IsPlaying = true;
            playingItem = item;
            bool isEqual = false;
            foreach (var item2 in this.videoList)
            {
                if (item2.Name == item.Name)
                {
                    isEqual = true;
                    item2.IsPlaying = true;
                }
                else
                {

                    item2.IsPlaying = false;
                }
            }
            if (!isEqual)
            {
                this.videoList.Add(item);
            }
            InitPlayListView(playingItem);
                CloseTwoPlay();
            this.player.Open(playingItem.Url);
            Btnplay.DM_Key = DMSkin.Controls.DMLabelKey.暂停;
        }
Beispiel #6
0
 /// <summary>
 /// 打开文件夹
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void 打开文件夹ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FolderBrowserDialog dialog = new FolderBrowserDialog();
     if (dialog.ShowDialog() == DialogResult.OK)
     {
         bool isEqual = false;
         PlayHelper.LoopFolder(dialog.SelectedPath, delegate (FileInfo file) {
             VideoItem item = new VideoItem(file.Name, file.FullName);
             if (PlayHelper.isRightExt(item))
             {
                 isEqual = false;
                 foreach (var item2 in this.videoList)
                 {
                     if (item2.Name == item.Name)
                     {
                         isEqual = true;
                         break;
                     }
                 }
                 if (!isEqual)
                 {
                     this.videoList.Add(item);
                 }
             }
         });
         if (this.player.GetState() == 0)
         {
             this.InitPlayListView(null);
         }
         else
         {
             this.InitPlayListView(this.playingItem);
         }
     }
 }
Beispiel #7
0
 /// <summary>
 /// 重绘播放列表
 /// </summary>
 public void InitPlayListView(VideoItem playingItem)
 {
     playListGrid.Items.Clear();
     Font f = new Font("微软雅黑", 10);
     if (videoList != null)
     {
         int indexY = 0;
         for (int i = 0; i < videoList.Count; i++)
         {
             Item it = new Item();
             it.Bounds = new Rectangle(0, indexY, 1920, 28);
             it.Text = videoList[i].Name;
             it.Url = videoList[i].Url;
             it.OnLine = videoList[i].IsPlaying;
             //it.OnLine =videoList[i].IsPlaying;
             playListGrid.Items.Add(it);
             indexY += 28;
         }
     }
 }