Exemplo n.º 1
0
        private async void DoBackgroundDownload(VideoDetail vd, VideosSource vs)
        {
            var downloadData = new DownloadData();

            downloadData.content = vd;
            int i = 0;

            foreach (var item in vs.RealUrl)
            {
                var filename = vd.ACTitle + "_" + vd.Title + "_" + i + ".flv";

                filename = filename.Replace("\\", "").Replace("/", "").Replace(":", "").Replace("*", "").Replace("?", "").
                           Replace("\"", "").Replace("<", "").Replace(">", "").Replace("|", "");
                var uri = new Uri(item);
                downloadData.VideoFiles.Add(filename);
                i++;
                //  List<Task> task = new List<Task>();
                try
                {
                    //task.Add(StartOneDownload(filename, uri, downloadData));
                    StartOneDownload(filename, uri, downloadData);
                }
                catch (Exception ex)
                {
                    LocalStorageFunc.DeleteVideoFile(filename);

                    foreach (var dd in downloadDatas)
                    {
                        if (dd.content.DanmakuId == vd.DanmakuId)
                        {
                            downloadDatas.Remove(dd);
                            break;
                        }
                    }
                    MSGSHOW("下载错误:\r\n     " + ex.Message);
                    return;
                }
                finally
                {
                }
            }

            downloadDatas.Add(downloadData);
        }
Exemplo n.º 2
0
        private async void PlayVideo(VideosSource vs)
        {
            var play_list = new SYEngine.Playlist(SYEngine.PlaylistTypes.NetworkHttp);

            foreach (var url in vs.AcUrl)
            {
                play_list.Append(url.url, url.size, (float)url.Time);
            }

            SYEngine.PlaylistNetworkConfigs cfgs = default(SYEngine.PlaylistNetworkConfigs);
            cfgs.HttpUserAgent       = "windows 10";
            cfgs.HttpUserAgent       = string.Empty;
            cfgs.HttpReferer         = string.Empty;
            cfgs.HttpCookie          = string.Empty;
            cfgs.UniqueId            = string.Empty;
            cfgs.DownloadRetryOnFail = true;
            play_list.NetworkConfigs = cfgs;
            Player.Source            = await play_list.SaveAndGetFileUriAsync();

            Player.Play();

            Player.MediaOpened += Player_MediaOpened;
            Player.MediaEnded  += Player_MediaEnded;
        }