private void webVideoList1_DownClick(TPlayerList.WebVideoListItem Item) { Video video = Item.Tag as Video; if (video.playInformation != null) { int selplayType = -1; if (video.playInformation.Count > 1) { List <string> seldata = new List <string>(); foreach (PlayAddress item in video.playInformation) { seldata.Add(item.playType); } UIListSel frm = new UIListSel(seldata); if (frm.ShowDialog() == DialogResult.OK) { selplayType = frm.SelIndex; } } else { selplayType = 0; } if (selplayType > -1) { string _colltag = "webvideo[okzy]_" + selplayType + "_" + video.id; List <PlayerItem> PlayList_Temp = new List <PlayerItem>(); if (video.playInformation[selplayType].videoUrl.Find(ab => ab.playURL.EndsWith(".mp4")) != null || video.playInformation[selplayType].videoUrl.Find(ab => ab.playURL.EndsWith(".m3u8")) != null) { foreach (VideoUrl item in video.playInformation[selplayType].videoUrl) { PlayList_Temp.Add(new PlayerItem("web", item.playURL, video.videoName + " - " + item.playName, _colltag)); } } else { foreach (VideoUrl item in video.playInformation[selplayType].videoUrl) { PlayList_Temp.Add(new PlayerItem("web_net1", item.playURL, video.videoName + " - " + item.playName, _colltag)); } } player.isTvModel = false; int coll = 0; if (SystemSettings.RememberLocation && File.Exists(Program.CachePath + "coll\\" + PlayList_Temp[0].colltag)) { int.TryParse(File.ReadAllText(Program.CachePath + "coll\\" + PlayList_Temp[0].colltag), out coll); } player.OpenFileWeb(PlayList_Temp, coll); } } else if (video.isRun) { Api.OpenMessage(this, MessageType.Info, "请稍后,正在获取地址"); } }
/// <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(); })); })); }
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; })); } }
private bool LoadingCover(string homeUrl, bool isshow = true) { string type = dataClass.baseType; try { CurrentVideos = dataClass.GetVideoList(homeUrl);//主页 if (CurrentVideos == null || CurrentVideos.titleVideos == null || CurrentVideos.titleVideos.Count == 0) { if (isshow) { Api.OpenMessage(this, MessageType.Warn, "没有获取到数据,请重试!"); } return(false); } thisURL = homeUrl; int index = webVideoList1.Items.Count; lock (webVideoList1.Items) { //Label_test.Text = CurrentVideos.pageCount + "页"; for (int i = 0; i < CurrentVideos.titleVideos.Count; i++) { Video video = CurrentVideos.titleVideos[i]; TPlayerList.WebVideoListItem webVideoListItem = new TPlayerList.WebVideoListItem { Name = video.videoName, Tag = video, //Img= video.videoImgUrl }; if (picCacheDataDAL.ExistsPic(video.id, type)) { using (DataTable dataTable = picCacheDataDAL.GetPicUrl(video.id.ToString(), type)) { foreach (DataRow item in dataTable.Rows) { var videoImg = (byte[])item["pictureImage"]; //int videoId = Convert.ToInt32(item["pictureID"]); video.videoImg = webVideoListItem.Img = videoImg.ToImage(); continue; } } } else { video.isRun = true; } webVideoList1.Items.Add(webVideoListItem); } } webVideoList1.InPaint(); SaveThumbnail(type, index, index + CurrentVideos.titleVideos.Count); return(true); } //catch (AggregateException ex1) //{ // if (isshow) // MessageBox.Show(ex1.ToString()); // return false; //} catch (Exception ex) { if (isshow) { Api.OpenMessage(this, MessageType.Error, ex.Message); } return(false); } }
/// <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(); })); })); }
private bool LoadingCover(string homeUrl, bool isshow = true) { try { TitleName CurrentVideos; var jsonData = OK_DataAPI.GetData(homeUrl); if (jsonData != null) { CurrentVideos = OK_DataAPI.GetVideoList(jsonData); } else { CurrentVideos = new TitleName { titleVideos = new List <Video>() }; } if (CurrentVideos == null || CurrentVideos.titleVideos == null || CurrentVideos.titleVideos.Count == 0) { if (isshow) { Api.OpenMessage(this, MessageType.Warn, "没有获取到数据,请重试!"); } return(false); } thisURL = homeUrl; int index = webVideoList1.Items.Count; lock (webVideoList1.Items) { //Label_test.Text = CurrentVideos.pageCount + "页"; for (int i = 0; i < CurrentVideos.titleVideos.Count; i++) { Video video = CurrentVideos.titleVideos[i]; TPlayerList.WebVideoListItem webVideoListItem = new TPlayerList.WebVideoListItem { Name = video.videoName, Tag = video, //Img= video.videoImgUrl }; if (picCacheDataDAL.ExistsPic(video.id, "OK_API")) { using (DataTable dataTable = picCacheDataDAL.GetPicUrl(video.id.ToString(), "OK_API")) { foreach (DataRow item in dataTable.Rows) { webVideoListItem.Img = ((byte[])item["pictureImage"]).ToImage(); continue; } } } webVideoList1.Items.Add(webVideoListItem); } } webVideoList1.InPaint(); SaveThumbnail(index, index + CurrentVideos.titleVideos.Count); return(true); } //catch (AggregateException ex1) //{ // if (isshow) // MessageBox.Show(ex1.ToString()); // return false; //} catch (Exception ex) { if (isshow) { Api.OpenMessage(this, MessageType.Error, ex.Message); } return(false); } }