Exemplo n.º 1
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            string videoUrl = VideoURL.Trim();

            if (!ValidationHelper.IsURL(videoUrl))
            {
                EventLogProvider.LogEvent(EventType.ERROR, "YouTubeVideo", "INVALIDVIDEOURL", String.Format("YouTube video web part couldn't load the video because the given URL is not valid: {0}", HTMLHelper.HTMLEncode(videoUrl)));
                return;
            }

            // If no wmode is set, append 'transparent' wmode. Fix IE issue with widget (widgets buttons are beyond YouTube video)
            if (String.IsNullOrEmpty(URLHelper.GetQueryValue(videoUrl, "wmode")))
            {
                videoUrl = URLHelper.UpdateParameterInUrl(videoUrl, "wmode", "transparent");
            }

            YouTubeVideoParameters ytParams = new YouTubeVideoParameters
            {
                Url           = videoUrl,
                FullScreen    = FullScreen,
                AutoPlay      = AutoPlay,
                RelatedVideos = Rel,
                Width         = Width,
                Height        = Height,
            };

            ltlPlaceholder.Text = MediaHelper.GetYouTubeVideo(ytParams);
        }
    }
Exemplo n.º 2
0
        async Task read(int index)
        {
            danmaku.ClearDanmu();
            media.Visibility       = Visibility.Collapsed;
            grid_status.Visibility = Visibility.Visible;
            cid         = infos[index].Cid;
            aid         = infos[0].Title;
            status.Text = "获取视频地址...";
            URL         = await ContentServ.GetVedioURL(cid, quality, format);

            status.Text += (URL == null)
                ? "失败"
                : $"{URL.Ps.Count}个{format}分段";
            if (URL == null)
            {
                return;
            }
            status.Text += Environment.NewLine + "加载弹幕数据...";
            try
            {
                DanmuPool = await GetDanmu(cid);
            }
            catch (Exception e)
            {
                status.Text += "失败" + e.Message;
            }
            if (format == VideoFormat.mp4)
            {
                // MP4只有一个分段(根据经验( ̄▽ ̄)")
                media.Source = new Uri(URL.Ps[0].Url);
            }
            else if (format == VideoFormat.flv)
            {
                // 先读第一个分段
                SetFFmpegSource(URL.Ps[0].Url);
            }
            if (URL.Ps.Count > 1)
            {
                // Flag该立的时候也得立啊
                // GetFlags();
            }
            _currentP      = URL.Ps[0];
            txt_title.Text = infos[index].Title;
            if (URL.Acceptquality.Contains("1"))
            {
                q1.Visibility = Visibility.Visible;
            }
            if (URL.Acceptquality.Contains("2"))
            {
                q2.Visibility = Visibility.Visible;
            }
            if (URL.Acceptquality.Contains("3"))
            {
                q3.Visibility = Visibility.Visible;
            }
            status.Text       += Environment.NewLine + "正在缓冲视频...";
            loading.Visibility = Visibility.Visible;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 开始下载
        /// </summary>
        private async void Btn_ok_Click(object sender, RoutedEventArgs e)
        {
            int i = 0;

            flyout_download.Hide();
            foreach (Pages item in ReadyList.SelectedItems)
            {
                try
                {
                    cid = item.Cid;
                    VideoURL url = await ContentServ.GetVedioURL(cid, quality, format);

                    string        name   = StringDeal.RemoveSpecial(title.Text);
                    string        part   = StringDeal.RemoveSpecial(item.Part);
                    StorageFolder folder = await DownloadHelper.GetMyFolderAsync();

                    StorageFolder f1 = await folder.CreateFolderAsync(name, CreationCollisionOption.OpenIfExists);

                    List <DownloadOperation> list = new List <DownloadOperation>();
                    for (int j = 0; j < url.Ps.Count; j++)
                    {
                        list.Add(await DownloadHelper.Download(url.Ps[j].Url, $"{part}_{j}.{format.ToString()}", f1));
                    }
                    // 如果await,那么执行完第一个StartAsync()后即退出循环.GetCurrentDownloadsAsync()方法同样会遇到此问题.(Download页)
                    IAsyncOperationWithProgress <DownloadOperation, DownloadOperation> start;
                    for (int k = 0; k < list.Count; k++)
                    {
                        start = list[k].StartAsync();
                    }
                    i++;
                    await DownloadHelper.AddVideoInfo(part, cid, details.Sid);

                    await popup.Show(i.ToString() + "个视频已加入下载队列");

                    if (SettingHelper.ContainsKey("_downdanmu"))
                    {
                        if ((bool)SettingHelper.GetValue("_downdanmu") == false)
                        {
                            continue;
                        }
                    }
                    await DownloadHelper.DownloadDanmakuAsync(cid, part, f1);
                }
                catch (Exception err)
                {
                    await popup.Show(err.Message);
                }
            }
            SwitchCommandBar(false);
        }
Exemplo n.º 4
0
 static void Main(string[] args)
 {
     try
     {
         VideoURL videoURL = SWFExtractor.Extract("http://www.hunantv.com/v/1/1/f/1827705.html");
         System.Console.WriteLine("Normal URL: " + videoURL.NormalURL);
         foreach (KeyValuePair <String, String> pair in videoURL.URLs)
         {
             System.Console.WriteLine(pair.Key + ": " + pair.Value);
         }
     }
     catch (Exception ex)
     {
         System.Console.WriteLine(ex.Message);
     }
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Audio    sing   = new Audio("Scorpions", new DateTime(1990), "Classic rok", "Wind of Change", 4970250, new TimeSpan(0, 5, 10), 320);
            Image    photo  = new Image("Unknown", new DateTime(1990), "AlbumArt", "Scorpions", 65536, "500x500");
            Video    clip   = new Video("Scorpions", new DateTime(1990), "Classic rok", "Wind of Change", 555, new TimeSpan(0, 5, 10), Quality.Best);
            AudioUrl sing1  = new AudioUrl("Scorpions", new DateTime(1990), "Classic rok", "Wind of Change", 4970250, new TimeSpan(0, 5, 10), 320, "http://mmm");
            ImageURL photo1 = new ImageURL("Unknown", new DateTime(1990), "AlbumArt", "Scorpions", 65536, "500x500", "http://mmm");
            VideoURL clip1  = new VideoURL("Scorpions", new DateTime(1990), "Classic rok", "Wind of Change", 555, new TimeSpan(0, 5, 10), Quality.Best, "http://mmm");


            Disk disk = new Disk("MyDisk", DateTime.Now);

            disk.Add(sing);
            disk.Add(photo);
            disk.Add(clip); // Error

            Serial serial = new Serial("MySerial", DateTime.Now);

            serial.Add(new Video("Scorpions", new DateTime(1990), "Classic rok", "Wind of Change", 555, new TimeSpan(0, 5, 10), Quality.Best));
            serial.Add(new Image("Unknown", new DateTime(1990), "AlbumArt", "Scorpions", 65536, "500x500"));
            serial.Add(new Audio("Scorpions", new DateTime(1990), "Classic rok", "Wind of Change", 4970250, new TimeSpan(0, 5, 10), 320)); // Error

            History history = new History("MyHistory", DateTime.Now);

            history.Add(photo);
            history.Add(photo1);
            history.Add(clip);
            history.Add(clip1);
            history.Add(sing); // Error

            Compilation comp = new Compilation("MyCompilation", DateTime.Now);

            comp.Add(sing);
            comp.Add(photo);
            comp.Add(sing1); //Error
            foreach (var i in comp)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine(i.OpenItem());
            }

            Console.ForegroundColor = ConsoleColor.White;
            // Console.WriteLine( history.OpenItem());

            Console.ReadKey();
        }
Exemplo n.º 6
0
        async Task read(int index)
        {
            danmaku.ClearDanmu();
            media.Visibility  = Visibility.Collapsed;
            status.Visibility = Visibility.Visible;
            cid         = infos[index].Cid;
            aid         = infos[0].Title;
            status.Text = "获取视频地址...";
            int quality = 2;

            if (SettingHelper.ContainsKey("_quality"))
            {
                quality = int.Parse(SettingHelper.GetValue("_quality").ToString());
            }
            URL = await ContentServ.GetVedioURL(cid, quality, VideoFormat.mp4);

            string url = URL.Url;

            status.Text += (URL == null) ? "失败" : "完毕";
            if (URL == null)
            {
                return;
            }
            status.Text += Environment.NewLine + "加载弹幕数据...";
            try
            {
                DanmuPool = await GetDanmu(cid);

                status.Text += "完毕";
            }
            catch
            {
                status.Text += "失败";
            }
            media.Source       = new Uri(url);
            txt_title.Text     = infos[index].Title;
            status.Text       += Environment.NewLine + "正在缓冲视频...";
            loading.Visibility = Visibility.Visible;
        }
Exemplo n.º 7
0
        private async void btn_ok_Click(object sender, RoutedEventArgs e)
        {
            int i = 0;

            foreach (Pages item in ReadyList.SelectedItems)
            {
                try
                {
                    cid = item.Cid;
                    VideoURL url = await ContentServ.GetVedioURL(cid, 2, VideoFormat.mp4);

                    string        name   = StringDeal.RemoveSpecial(title.Text);
                    string        part   = StringDeal.RemoveSpecial(item.Part);
                    StorageFolder folder = await KnownFolders.VideosLibrary.CreateFolderAsync("哔哩哔哩", CreationCollisionOption.OpenIfExists);

                    StorageFolder f1 = await folder.CreateFolderAsync(name, CreationCollisionOption.OpenIfExists);

                    var download = await DownloadHelper.Download(url.Url, part + ".mp4", f1);

                    if (SettingHelper.ContainsKey("_downdanmu"))
                    {
                        if ((bool)SettingHelper.GetValue("_downdanmu") == true)
                        {
                            string xml = await BaseService.SentGetAsync("http://comment.bilibili.com/" + cid + ".xml");

                            StorageFile file = await f1.CreateFileAsync(part + ".xml");

                            using (Stream file0 = await file.OpenStreamForWriteAsync())
                            {
                                using (StreamWriter writer = new StreamWriter(file0))
                                {
                                    writer.Write(xml);
                                }
                            }
                        }
                    }
                    else
                    {
                        string xml = await BaseService.SentGetAsync("http://comment.bilibili.com/" + cid + ".xml");

                        StorageFile file = await f1.CreateFileAsync(name + ".xml");

                        using (Stream file0 = await file.OpenStreamForWriteAsync())
                        {
                            using (StreamWriter writer = new StreamWriter(file0))
                            {
                                writer.Write(xml);
                            }
                        }
                    }
                    //如果await,那么执行完第一个StartAsync()后即退出循环.GetCurrentDownloadsAsync()方法同样会遇到此问题.(Download页)
                    IAsyncOperationWithProgress <DownloadOperation, DownloadOperation> start = download.StartAsync();
                    i++;
                    messagepop.Show(i.ToString() + "个视频已加入下载队列");
                }
                catch (Exception err)
                {
                    messagepop.Show(err.Message);
                }
            }
        }