private void 播放窗口退出事件(object sender, EventArgs e)
 {
     NewThreadTask.Run(() =>
     {
         MMPU.当前直播窗口数量--;
         PlayW.MainWindow p = (PlayW.MainWindow)sender;
         playList1.Remove(p);
         foreach (var item in MMPU.DownList)
         {
             if (item.DownIofo.事件GUID == p.DD.DownIofo.事件GUID)
             {
                 item.DownIofo.WC.CancelAsync();
                 item.DownIofo.载状态  = false;
                 item.DownIofo.备注   = "播放串口关闭,停止下载";
                 item.DownIofo.结束时间 = Convert.ToInt32((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
                 if (item.DownIofo.是否保存)
                 {
                 }
                 else
                 {
                     MMPU.文件删除委托(p.DD.DownIofo.文件保存路径);
                 }
                 break;
             }
         }
     });
 }
예제 #2
0
 private void 播放窗口退出事件(object sender, EventArgs e)
 {
     try
     {
         new Thread(new ThreadStart(delegate {
             MMPU.当前直播窗口数量--;
             PlayW.MainWindow p = (PlayW.MainWindow)sender;
             foreach (var item in MMPU.DownList)
             {
                 if (item.DownIofo.事件GUID == p.DD.DownIofo.事件GUID)
                 {
                     item.DownIofo._wc.CancelAsync();
                     item.DownIofo.载状态  = false;
                     item.DownIofo.结束时间 = Convert.ToInt32((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
                     if (item.DownIofo.是否保存)
                     {
                     }
                     else
                     {
                         MMPU.文件删除委托(p.DD.DownIofo.文件保存路径);
                     }
                     break;
                 }
             }
         })).Start();
     }
     catch (Exception)
     {
     }
 }
예제 #3
0
        public static void DDTV关闭事件()
        {
            MessageBoxResult dr = System.Windows.MessageBox.Show("确定退出DDTV?", "退出", MessageBoxButton.OKCancel, MessageBoxImage.Question);

            if (dr == MessageBoxResult.OK)
            {
                new Thread(new ThreadStart(delegate
                {
                    try
                    {
                        FileInfo[] files = new DirectoryInfo("./tmp/LiveCache/").GetFiles();
                        foreach (var item in files)
                        {
                            MMPU.文件删除委托("./tmp/LiveCache/" + item.Name);
                        }
                    }
                    catch (Exception)
                    {
                    }
                    Environment.Exit(0);
                })).Start();
            }
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="提示内容"></param>
        /// <param name="来源">真为手动,假为自动</param>
        public void 刷新播放(string 提示内容, bool 来源)
        {
            this.Dispatcher.Invoke(new Action(delegate
            {
                提示框.Visibility = Visibility.Visible;
                提示文字.Content   = 提示内容;
            }));
            switch (DD.DownIofo.平台)
            {
            case "bilibili":
            {
                if (bilibili.根据房间号获取房间信息.是否正在直播(DD.DownIofo.房间_频道号, true))
                {
                    new Task((() =>
                        {
                            ///需要DEBUG:CancelAsync过后,刷新播放没有显示出来
                            DD.DownIofo.WC.CancelAsync();
                            DD.DownIofo.备注 = "播放刷新";
                            DD.DownIofo.载状态 = false;
                            DD.DownIofo.结束时间 = Convert.ToInt32((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
                            Downloader 载对象 = Downloader.新建下载对象(DD.DownIofo.平台, DD.DownIofo.房间_频道号, bilibili.根据房间号获取房间信息.获取标题(DD.DownIofo.房间_频道号), Guid.NewGuid().ToString(), bilibili.根据房间号获取房间信息.载地址(DD.DownIofo.房间_频道号), "播放缓冲重连", false, DD.DownIofo.主播名称, false, null);
                            MMPU.文件删除委托(DD.DownIofo.文件保存路径, "刷新播放窗口,删除LiveCache过期的缓存文件");
                            DD = 载对象;
                            for (int i = 0; i < MMPU.播放缓冲时长; i++)
                            {
                                Thread.Sleep(1000);
                                if (载对象.DownIofo.已下载大小bit > 1000)
                                {
                                    Thread.Sleep(MMPU.播放缓冲时长 * 1000);
                                    try
                                    {
                                        Play_Open(载对象.DownIofo.文件保存路径);
                                        //this.VlcControl.SourceProvider.MediaPlayer.Play(new Uri(下载对象.DownIofo.文件保存路径));
                                    }
                                    catch (Exception)
                                    {
                                        return;
                                    }
                                    this.Dispatcher.Invoke(new Action(delegate
                                    {
                                        DD = 载对象;
                                        提示框.Visibility = Visibility.Collapsed;
                                    }));
                                    return;
                                }
                                else
                                {
                                    this.Dispatcher.Invoke(new Action(delegate
                                    {
                                        提示文字.Content = "直播源推流停止或卡顿,正在尝试重连,第" + (i + 1) + "次失败/一共尝试" + MMPU.播放缓冲时长 + "次";
                                        if (i >= MMPU.播放缓冲时长 - 1)
                                        {
                                            提示文字.Content += "\n请尝试重开播放窗口";
                                            return;
                                        }
                                    }));
                                }
                            }
                        })).Start();
                }
                else
                {
                    InfoLog.InfoPrintf(DD.DownIofo.房间_频道号 + "房间:" + DD.DownIofo.主播名称 + " 下播放,录制完成", InfoLog.InfoClass.载必要提示);
                    this.Dispatcher.Invoke(new Action(delegate
                        {
                            提示文字.Content = "======该房间/频道 直播停止,请关闭播放窗口======";
                            return;
                        }));
                }
                break;
            }

            default:
                System.Windows.MessageBox.Show("发现了与当前版本不支持的平台,请检查更新");
                this.Dispatcher.Invoke(new Action(delegate
                {
                    提示框.Visibility = Visibility.Collapsed;
                }));
                return;
            }
        }
예제 #5
0
        public void 刷新播放(string 提示内容)
        {
            this.Dispatcher.Invoke(new Action(delegate
            {
                提示框.Visibility = Visibility.Visible;
                提示文字.Content   = 提示内容;
            }));
            switch (DD.DownIofo.平台)
            {
            case "bilibili":
            {
                if (bilibili.根据房间号获取房间信息.是否正在直播(DD.DownIofo.房间_频道号))
                {
                    new Thread(new ThreadStart(delegate
                        {
                            DD.DownIofo._wc.CancelAsync();
                            DD.DownIofo.备注 = "用户取消";
                            Downloader 载对象 = Downloader.新建下载对象(DD.DownIofo.平台, DD.DownIofo.房间_频道号, bilibili.根据房间号获取房间信息.获取标题(DD.DownIofo.房间_频道号), Guid.NewGuid().ToString(), bilibili.根据房间号获取房间信息.载地址(DD.DownIofo.房间_频道号), "播放缓冲重连", false);
                            MMPU.文件删除委托(DD.DownIofo.文件保存路径);
                            DD = 载对象;
                            for (int i = 0; i < 3; i++)
                            {
                                Thread.Sleep(1000);
                                if (载对象.DownIofo.已下载大小bit > 1000)
                                {
                                    Thread.Sleep(1000);
                                    this.VlcControl.SourceProvider.MediaPlayer.Play(new Uri(载对象.DownIofo.文件保存路径));
                                    this.Dispatcher.Invoke(new Action(delegate
                                    {
                                        提示框.Visibility = Visibility.Collapsed;
                                    }));
                                    return;
                                }
                                else
                                {
                                    this.Dispatcher.Invoke(new Action(delegate
                                    {
                                        提示文字.Content = "直播源推流停止或卡顿,正在尝试重连,第" + (i + 1) + "次失败/一共尝试3次";
                                        if (i == 2)
                                        {
                                            提示文字.Content += "\n请尝试重开播放窗口";
                                            return;
                                        }
                                    }));
                                }
                            }
                        })).Start();
                }
                else
                {
                    this.Dispatcher.Invoke(new Action(delegate
                        {
                            提示文字.Content = "该房间/频道 直播停止..";
                            return;
                        }));
                }
                break;
            }

            default:
                System.Windows.MessageBox.Show("发现了与当前版本不支持的平台,请检查更新");
                this.Dispatcher.Invoke(new Action(delegate
                {
                    提示框.Visibility = Visibility.Collapsed;
                }));
                return;
            }
        }