コード例 #1
0
ファイル: WebApiVideo.cs プロジェクト: Haku-Men/TPlayer
        /// <summary>
        /// 图片加载线程
        /// </summary>
        private void SaveThumbnail(int start, int end)
        {
            Action _action = () =>
            {
                for (int i = start; i < end; i++)
                {
                    TPlayerList.WebVideoListItem itemsv = webVideoList1.Items[i];
                    if (itemsv.Img == null)
                    {
                        Video video = itemsv.Tag as Video;

                        HttpLib.WebResult webResult;
                        byte[]            data = HttpLib.Http.Get(video.videoImgUrl).redirect(true).requestData(out webResult);

                        if (webResult != null)
                        {
                            itemsv.Img = data.ToImage();
                            PicCacheData picdata = new PicCacheData();//保存封面缩略图
                            picdata.pictureID    = video.id;
                            picdata.pictureImage = data;
                            picdata.picType      = "OK_API";
                            picCacheDataDAL.InsertPicUrl(picdata);
                        }
                    }
                }
            };

            _task.ContinueWhenAll(new Task[] { _task.StartNew(_action) }, (action =>
            {
                webVideoList1.InPaint();
                this.Invoke(new Action(() =>
                {
                    webVideoList1.Invalidate();
                }));
            }));
        }
コード例 #2
0
ファイル: WebVideo.cs プロジェクト: Haku-Men/TPlayer
        private void webVideoList1_DownClick(TPlayerList.WebVideoListItem Item)
        {
            Video video = Item.Tag as Video;

            if (video.playInformation != null)
            {
                if (timer1.Enabled)
                {
                    timer1.Enabled = false;
                    if (isgo != -1)
                    {
                        isgo = -1;
                        //isgo = true;
                        pictureBox2.Image = FontAwesome.GetImage(fontlogo, "4FBB", 38, Color.Black);
                    }
                }
                if (webVideoDetail != null)
                {
                    webVideoDetail.Close();
                }
                webVideoDetail = new WebVideoDetail(this, video, dataClass.baseType);
                webVideoDetail.Show(this);
            }
            else if (video.isRun)
            {
                Api.OpenMessage(this, MessageType.Info, "请稍后,正在获取地址");
            }
            else
            {
                timer1.Enabled = true;
                video.isRun    = true;
                bool   isOk    = false;
                Action _action = () =>
                {
                    Video vs       = dataClass.GetVideoInfo(video.id);
                    int   errCount = 0;
                    while (vs == null)
                    {
                        System.Threading.Thread.Sleep(500);
                        vs = dataClass.GetVideoInfo(video.id);
                        errCount++;
                        if (errCount > 5)
                        {
                            break;
                        }
                    }

                    if (vs != null)
                    {
                        isOk                  = true;
                        video.videoName       = vs.videoName;
                        video.videoImgUrl     = vs.videoImgUrl;
                        video.videoType       = vs.videoType;
                        video.videoQuality    = vs.videoQuality;
                        video.videoTotalInfo  = vs.videoTotalInfo;
                        video.videoSynopsis   = vs.videoSynopsis;
                        video.playInformation = vs.playInformation;
                        if (Item.Img == null)
                        {
                            HttpLib.WebResult webResult;
                            byte[]            data = HttpLib.Http.Get(vs.videoImgUrl).redirect(true).requestData(out webResult);

                            if (webResult != null)
                            {
                                video.videoImg = Item.Img = data.ToImage();
                                PicCacheData picdata = new PicCacheData
                                {
                                    pictureID    = video.id,
                                    pictureImage = data,
                                    picType      = dataClass.baseType,
                                };//保存封面缩略图
                                picCacheDataDAL.InsertPicUrl(picdata);
                            }
                        }
                    }
                };
                _task.ContinueWhenAll(new Task[] { _task.StartNew(_action) }, (action =>
                {
                    if (isOk)
                    {
                        this.BeginInvoke(new Action(() =>
                        {
                            webVideoList1_DownClick(Item);
                        }));
                    }
                    else
                    {
                        Api.OpenMessage(this, MessageType.Warn, "地址获取失败!");
                    }
                    video.isRun = false;
                }));
            }
        }
コード例 #3
0
ファイル: WebVideo.cs プロジェクト: Haku-Men/TPlayer
        /// <summary>
        /// 图片加载线程
        /// </summary>
        private void SaveThumbnail(string type, int start, int end)
        {
            Action _action = () =>
            {
                for (int i = start; i < end; i++)
                {
                    TPlayerList.WebVideoListItem itemsv = webVideoList1.Items[i];
                    if (itemsv.Img == null)
                    {
                        Video video    = itemsv.Tag as Video;
                        Video vs       = dataClass.GetVideoInfo(video.id);
                        int   errCount = 0;
                        while (vs == null)
                        {
                            System.Threading.Thread.Sleep(500);
                            vs = dataClass.GetVideoInfo(video.id);
                            errCount++;
                            if (errCount > 5)
                            {
                                break;
                            }
                        }

                        if (vs != null)
                        {
                            video.videoName      = vs.videoName;
                            video.videoImgUrl    = vs.videoImgUrl;
                            video.videoType      = vs.videoType;
                            video.videoQuality   = vs.videoQuality;
                            video.videoTotalInfo = vs.videoTotalInfo;
                            video.videoSynopsis  = vs.videoSynopsis;

                            video.playInformation = vs.playInformation;

                            HttpLib.WebResult webResult;
                            byte[]            data = HttpLib.Http.Get(vs.videoImgUrl).redirect(true).requestData(out webResult);
                            if (webResult != null)
                            {
                                video.videoImg = itemsv.Img = data.ToImage();
                                PicCacheData picdata = new PicCacheData
                                {
                                    pictureID    = video.id,
                                    pictureImage = data,
                                    picType      = type,
                                };//保存封面缩略图
                                picCacheDataDAL.InsertPicUrl(picdata);
                            }
                        }
                        video.isRun = false;
                    }
                }
            };

            _task.ContinueWhenAll(new Task[] { _task.StartNew(_action) }, (action =>
            {
                webVideoList1.InPaint();
                this.Invoke(new Action(() =>
                {
                    webVideoList1.Invalidate();
                }));
            }));
        }