コード例 #1
0
 private void lsv_DoubleClick(object sender, EventArgs e)
 {
     if (lsv.SelectedIndices.Count > 0)
     {
         int          index = lsv.SelectedIndices[0];
         ListViewItem lvi   = lsv.Items[index];
         if (lvi.Group == lsv.Groups["VideoGroup"])
         {
             //显示设置窗口
             Video    v    = new Video();
             string[] time = lsv.Items[index].SubItems[1].Text.Split(':', '.');
             TimeSpan ts   = new TimeSpan(0, int.Parse(time[0]), int.Parse(time[1]), int.Parse(time[2]), int.Parse(time[3]));
             v.Length   = (int)ts.TotalMilliseconds;
             v.FileName = lsv.Items[index].SubItems[2].Text;
             AcPlayItem form = new AcPlayItem(v);
             form.ShowDialog();
             //重新设置ListViewItem
             lsv.Items[index].SubItems[0].Text = Path.GetFileName(v.FileName);
             ts = new TimeSpan(0, 0, 0, 0, v.Length);
             lsv.Items[index].SubItems[1].Text = ts.Hours.ToString() + ":" + ts.Minutes.ToString("D2") + ":" + ts.Seconds.ToString("D2") + "." + ts.Milliseconds.ToString("D3");
             lsv.Items[index].SubItems[2].Text = v.FileName;
         }
     }
 }
コード例 #2
0
        private void AddFile(string file)
        {
            var lvi = new ListViewItem();

            file = file.ToUpper();
            //判断文件格式
            if (file.EndsWith(".XML") || file.EndsWith(".JSON"))             //如果是弹幕文件
            {
                //文件名
                lvi.Text = Path.GetFileName(file);
                //弹幕文件
                try
                {
                    if (File.OpenText(file).ReadLine().StartsWith("[{"))                     //acfun
                    {
                        lvi.SubItems.Add("Acfun弹幕文件");
                    }
                    else if (File.OpenText(file).ReadToEnd().Contains(@"<chatserver>chat.bilibili.tv</chatserver>"))
                    {
                        lvi.SubItems.Add("Bilibili弹幕文件");
                    }
                    else if (File.OpenText(file).ReadToEnd().Contains(@"""status"":""OK"""))
                    {
                        lvi.SubItems.Add("豆泡弹幕文件");
                    }
                    else
                    {
                        lvi.SubItems.Add("未知格式弹幕文件");
                    }
                }
                catch (Exception)
                {
                    lvi.SubItems.Add("未知格式弹幕文件");
                }
                lvi.SubItems.Add(file);
                //设置Group
                lvi.Group = lsv.Groups["SubtitleGroup"];
                //设置图标
                lvi.ImageIndex = 1;
            }
            else if (file.EndsWith(".FLV") || file.EndsWith(".MP4") || file.EndsWith(".HLV") || file.EndsWith(".F4V"))             //如果是视频文件
            {
                Video v = new Video();
                v.FileName = file;
                //判断文件长度
                //v.Length = 100;
                v.Length = 0;
                AcPlayItem form = new AcPlayItem(v);
                form.ShowDialog();
                //设置文件名和长度
                lvi.Text = Path.GetFileName(v.FileName);
                TimeSpan ts = new TimeSpan(0, 0, 0, 0, v.Length);
                lvi.SubItems.Add(ts.Hours.ToString() + ":" + ts.Minutes.ToString("D2") + ":" + ts.Seconds.ToString("D2") + "." + ts.Milliseconds.ToString("D3"));
                lvi.SubItems.Add(v.FileName);
                //设置Group
                lvi.Group = lsv.Groups["VideoGroup"];
                //设置图标
                lvi.ImageIndex = 0;
            }
            else
            {
                return;
            }

            //添加listviewitem
            lsv.Items.Add(lvi);
        }
コード例 #3
0
ファイル: AcPlay2.cs プロジェクト: renning22/SnifferPlayer
 private void lsv_DoubleClick(object sender, EventArgs e)
 {
     if (lsv.SelectedIndices.Count > 0)
     {
         int index = lsv.SelectedIndices[0];
         ListViewItem lvi = lsv.Items[index];
         if (lvi.Group == lsv.Groups["VideoGroup"])
         {
             //显示设置窗口
             Video v = new Video();
             string[] time = lsv.Items[index].SubItems[1].Text.Split(':', '.');
             TimeSpan ts = new TimeSpan(0, int.Parse(time[0]), int.Parse(time[1]), int.Parse(time[2]), int.Parse(time[3]));
             v.Length = (int)ts.TotalMilliseconds;
             v.FileName = lsv.Items[index].SubItems[2].Text;
             AcPlayItem form = new AcPlayItem(v);
             form.ShowDialog();
             //重新设置ListViewItem
             lsv.Items[index].SubItems[0].Text = Path.GetFileName(v.FileName);
             ts = new TimeSpan(0, 0, 0, 0, v.Length);
             lsv.Items[index].SubItems[1].Text = ts.Hours.ToString() + ":" + ts.Minutes.ToString("D2") + ":" + ts.Seconds.ToString("D2") + "." + ts.Milliseconds.ToString("D3");
             lsv.Items[index].SubItems[2].Text = v.FileName;
         }
     }
 }
コード例 #4
0
ファイル: AcPlay2.cs プロジェクト: renning22/SnifferPlayer
        private void AddFile(string file)
        {
            var lvi = new ListViewItem();

            //判断文件格式
            if (file.EndsWith(".xml") || file.EndsWith(".json")) //如果是弹幕文件
            {
                //文件名
                lvi.Text = Path.GetFileName(file);
                //弹幕文件
                try
                {
                    if (File.OpenText(file).ReadLine().StartsWith("[{")) //acfun
                    {
                        lvi.SubItems.Add("Acfun弹幕文件");
                    }
                    else if (File.OpenText(file).ReadToEnd().Contains(@"<chatserver>chat.bilibili.tv</chatserver>"))
                    {
                        lvi.SubItems.Add("Bilibili弹幕文件");
                    }
                    else
                    {
                        lvi.SubItems.Add("未知格式弹幕文件");
                    }
                }
                catch (Exception)
                {
                    lvi.SubItems.Add("未知格式弹幕文件");
                }
                lvi.SubItems.Add(file);
                //设置Group
                lvi.Group = lsv.Groups["SubtitleGroup"];
                //设置图标
                lvi.ImageIndex = 1;
            }
            else if (file.EndsWith(".flv") || file.EndsWith(".mp4") || file.EndsWith(".hlv") || file.EndsWith(".f4v")) //如果是视频文件
            {
                Video v = new Video();
                v.FileName = file;
                //判断文件长度
                //v.Length = 100;
                v.Length = 0;
                AcPlayItem form = new AcPlayItem(v);
                form.ShowDialog();
                //设置文件名和长度
                lvi.Text = Path.GetFileName(v.FileName);
                TimeSpan ts = new TimeSpan(0, 0, 0, 0, v.Length);
                lvi.SubItems.Add(ts.Hours.ToString() + ":" + ts.Minutes.ToString("D2") + ":" + ts.Seconds.ToString("D2") + "." + ts.Milliseconds.ToString("D3"));
                lvi.SubItems.Add(v.FileName);
                //设置Group
                lvi.Group = lsv.Groups["VideoGroup"];
                //设置图标
                lvi.ImageIndex = 0;
            }
            else
            {
                return;
            }

            //添加listviewitem
            lsv.Items.Add(lvi);
        }