public void AddDownVideo(VideoInfo videoInfo) { if (videoInfo.downloadUrl != null && videoInfo.downloadUrl.Count == 0) { App.ShowToast(videoInfo.name + " 没有可用下载链接"); return; } DownVideoInfoViewMoel video = new DownVideoInfoViewMoel(); video.Name = videoInfo.name; video.Image = videoInfo.image; video.Time = videoInfo.time; video.VideoId = videoInfo.videoId; video.VideoIndex = videoInfo.videoIndex; video.Desc = videoInfo.desc; video.IsLoading = false; video.IsLoaded = false; int downIndex = 0; for (int i = 0; i < videoInfo.downloadUrl.Count; i++) { if (videoInfo.downloadUrl[i].name == App.DownVideoModel.CurrentDefinitionName) { downIndex = i; break; } } video.DownUrl = videoInfo.downloadUrl[downIndex].url; DowningVideo.Add(video); DowningVideoids.Add(video.VideoId); SaveVideoData(); BeginDownVideos(); }
public void BeginDownVideos() { //PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled; if (CommonData.NetworkStatus != "WiFi" || isDownding || DowningVideo.Count == 0) { return; } isDownding = true; currentDownVideo = DowningVideo[0]; System.Diagnostics.Debug.WriteLine("视频地址:" + currentDownVideo.DownUrl); HttpHelper.httpGet(currentDownVideo.DownUrl, (ar) => { string result = HttpHelper.SyncResultTostring(ar); if (result != null) { ResourceInfo videosResult = null; try { videosResult = JsonConvert.DeserializeObject <ResourceInfo>(result); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("LoadChannelCompleted json 解析错误" + ex.Message); App.JsonError(result); } if (videosResult != null && videosResult.status == "ok" && videosResult.info != null) { CallbackManager.currentPage.Dispatcher.BeginInvoke(() => { currentDownVideo.IsLoading = true; currentDownVideo.IsLoadError = false; HttpHelper.httpGet(currentDownVideo.Image, (imageAr) => { byte[] imgdata = HttpHelper.SyncResultToByte(imageAr); if (imgdata != null) { string imageType = currentDownVideo.Image.Remove(0, currentDownVideo.Image.Length - 4); WpStorage.SaveFilesToIsoStore(CommonData.videoSavePath + currentDownVideo.VideoId.ToString() + imageType, imgdata); currentDownVideo.LocalImage = CommonData.videoSavePath + currentDownVideo.VideoId.ToString() + imageType; } }); DownloadFile(videosResult.info); }); } } else { //todo } }); }
public void BeginDownVideos() { //PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled; if (CommonData.NetworkStatus != "WiFi" || isDownding || DowningVideo.Count == 0) { return; } isDownding = true; currentDownVideo = DowningVideo[0]; System.Diagnostics.Debug.WriteLine("视频地址:" + currentDownVideo.DownUrl); HttpHelper.httpGet(currentDownVideo.DownUrl, (ar) => { string result = HttpHelper.SyncResultTostring(ar); if (result != null) { ResourceInfo videosResult = null; try { videosResult = JsonConvert.DeserializeObject<ResourceInfo>(result); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("LoadChannelCompleted json 解析错误" + ex.Message); App.JsonError(result); } if (videosResult != null && videosResult.status == "ok" && videosResult.info != null) { CallbackManager.currentPage.Dispatcher.BeginInvoke(() => { currentDownVideo.IsLoading = true; currentDownVideo.IsLoadError = false; HttpHelper.httpGet(currentDownVideo.Image, (imageAr) => { byte[] imgdata = HttpHelper.SyncResultToByte(imageAr); if (imgdata != null) { string imageType = currentDownVideo.Image.Remove(0, currentDownVideo.Image.Length - 4); WpStorage.SaveFilesToIsoStore(CommonData.videoSavePath + currentDownVideo.VideoId.ToString() + imageType, imgdata); currentDownVideo.LocalImage = CommonData.videoSavePath + currentDownVideo.VideoId.ToString() + imageType; } }); DownloadFile(videosResult.info); }); } } else { //todo } }); }
public void AddRememberVideo(VideoInfo videoInfo) { DownVideoInfoViewMoel video = new DownVideoInfoViewMoel(); video.Name = videoInfo.name; video.Image = videoInfo.image; video.VideoId = videoInfo.videoId; HttpHelper.httpGet(video.Image, (imageAr) => { byte[] imgdata = HttpHelper.SyncResultToByte(imageAr); if (imgdata != null) { string imageType = video.Image.Remove(0, video.Image.Length - 4); WpStorage.SaveFilesToIsoStore(CommonData.rememberVideoSavePath + video.VideoId.ToString() + imageType, imgdata); video.LocalImage = CommonData.rememberVideoSavePath + video.VideoId.ToString() + imageType; } CallbackManager.currentPage.Dispatcher.BeginInvoke(() => { //检查记录是否相同 相同则删除相同项 for (int i = 0; i < RememberVideos.Count; i++) { if (RememberVideos[i].VideoId == video.VideoId) { RememberVideos.RemoveAt(i); break; } } if (RememberVideos.Count > 20) { RememberVideos.RemoveAt(0); } RememberVideos.Add(video); //检查最近记录是否相同 相同则删除相同项 for (int i = 0; i < LastVideoRemember.Count; i++) { if (LastVideoRemember[i].VideoId == video.VideoId) { LastVideoRemember.RemoveAt(i); break; } } if (LastVideoRemember.Count > 1) { LastVideoRemember.RemoveAt(0); } LastVideoRemember.Add(video); SaveRememberVideoData(); }); }); }
public void AddRememberVideo(VideoInfo videoInfo) { DownVideoInfoViewMoel video = new DownVideoInfoViewMoel(); video.Name = videoInfo.name; video.Image = videoInfo.image; video.VideoId = videoInfo.videoId; HttpHelper.httpGet(video.Image, (imageAr) => { byte[] imgdata = HttpHelper.SyncResultToByte(imageAr); if (imgdata != null) { string imageType = video.Image.Remove(0, video.Image.Length - 4); WpStorage.SaveFilesToIsoStore(CommonData.rememberVideoSavePath + video.VideoId.ToString() + imageType, imgdata); video.LocalImage =CommonData.rememberVideoSavePath + video.VideoId.ToString() + imageType; } CallbackManager.currentPage.Dispatcher.BeginInvoke(() => { //检查记录是否相同 相同则删除相同项 for (int i = 0; i < RememberVideos.Count; i++) { if (RememberVideos[i].VideoId == video.VideoId) { RememberVideos.RemoveAt(i); break; } } if (RememberVideos.Count > 20) { RememberVideos.RemoveAt(0); } RememberVideos.Add(video); //检查最近记录是否相同 相同则删除相同项 for (int i = 0; i < LastVideoRemember.Count; i++) { if (LastVideoRemember[i].VideoId == video.VideoId) { LastVideoRemember.RemoveAt(i); break; } } if (LastVideoRemember.Count > 1) { LastVideoRemember.RemoveAt(0); } LastVideoRemember.Add(video); SaveRememberVideoData(); }); }); }
public void AddDownVideo(VideoInfo videoInfo) { if (videoInfo.downloadUrl!=null && videoInfo.downloadUrl.Count == 0) { App.ShowToast(videoInfo.name+" 没有可用下载链接"); return; } DownVideoInfoViewMoel video = new DownVideoInfoViewMoel(); video.Name = videoInfo.name; video.Image = videoInfo.image; video.Time = videoInfo.time; video.VideoId = videoInfo.videoId; video.VideoIndex = videoInfo.videoIndex; video.Desc = videoInfo.desc; video.IsLoading = false; video.IsLoaded = false; int downIndex = 0; for(int i=0;i<videoInfo.downloadUrl.Count;i++){ if (videoInfo.downloadUrl[i].name == App.DownVideoModel.CurrentDefinitionName) { downIndex = i; break; } } video.DownUrl = videoInfo.downloadUrl[downIndex].url; DowningVideo.Add(video); DowningVideoids.Add(video.VideoId); SaveVideoData(); BeginDownVideos(); }