void playFac_GetPlayInfoSucceed(object sender, HttpFactoryArgs <PlayInfo> args) { ProgramInfo curProgramInfo = _downProgramInfo[sender as PlayInfoFactory]; PlayInfo.Item item = args.Result.GetItemByFileType(5); if (item == null) { // _downSign.Visibility = Visibility.Collapsed; _downSign.Foreground = new SolidColorBrush(Colors.White); if (_piForDownload != null) { _piForDownload.IsDown = Visibility.Collapsed; } string id = string.Empty; if (curProgramInfo == null) { id = DetailPageHelp.ChannelDetailInfoForPrograms.VID.ToString() + "||"; } else { id = DetailPageHelp.ChannelDetailInfoForPrograms.VID + "|" + curProgramInfo.Index + "|" + curProgramInfo.ChannelVID; } foreach (DownPage.DownInfo info in DownPage.MyDownloading) { if (info.VID == id) { DownPage.MyDownloading.Remove(info); break; } } DownPage.DownFactory.DeleteRecord(id); MessageBox.Show("无法下载该文件", "提示", MessageBoxButton.OK); return; } _rid = item.Rid; if (item.DtInfo != null) { _downUrl = item.url; if (curProgramInfo == null) { DownPage.UpdateTask(DetailPageHelp.ChannelDetailInfoForPrograms.VID.ToString() + "||", _downUrl); } else { DownPage.UpdateTask(DetailPageHelp.ChannelDetailInfoForPrograms.VID + "|" + curProgramInfo.Index + "|" + curProgramInfo.ChannelVID, _downUrl); } } else { string jump_url = "http://wp7.jump.synacast.com/" + item.Rid + "dt?type=mwp7"; PPTVData.HttpWebClient jumpWebClient = new PPTVData.HttpWebClient(); jumpWebClient.DownloadStringCompleted += new PPTVData.DownloadStringCompletedEventHandler(JumpWebClientDownloadStringCompleted); jumpWebClient.DownloadStringAsync(jump_url); } }
private void JumpWebClientDownloadStringCompleted(object sender, PPTVData.DownloadStringCompletedEventArgs e) { string mediaServerHost = String.Empty; string serverTime = String.Empty; DateTime serverBaseTime; DateTime localBaseTime; if (e.Error == null) { try { using (XmlReader reader = XmlReader.Create(new System.IO.StringReader(e.Result))) { if (true == reader.ReadToFollowing("server_host")) { mediaServerHost = reader.ReadElementContentAsString("server_host", ""); } reader.ReadToFollowing("server_time"); serverTime = reader.ReadElementContentAsString("server_time", ""); System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US"); serverBaseTime = DateTime.ParseExact(serverTime, "ddd MMM dd HH:mm:ss yyyy UTC", ci); localBaseTime = DateTime.Now; _downUrl = String.Format("http://{0}/{1}?type=wp7&w=1&key={2}", mediaServerHost, _rid, PPTVData.KeyGenerator.GetKey(serverBaseTime)); if (DetailPageHelp.ChannelDetailInfoForPrograms.ProgramInfos == null || DetailPageHelp.ChannelDetailInfoForPrograms.ProgramInfos.Count() <= 1) { DownPage.UpdateTask(DetailPageHelp.ChannelDetailInfoForPrograms.VID.ToString() + "||", _downUrl); } else { DownPage.UpdateTask(DetailPageHelp.ChannelDetailInfoForPrograms.VID + "|" + _piForDownload.Index + "|" + _piForDownload.ChannelVID, _downUrl); } if (_downSign != null) { _downSign.Foreground = App.Current.Resources["Orange"] as SolidColorBrush;; //_downSign.Visibility = Visibility.Visible; if (_piForDownload != null) { _piForDownload.IsDown = Visibility.Visible; } Utils.CustomAnimation.DownloadAnimation(xDownAnima); } } } catch (Exception) { } } }
void playFac_GetPlayInfoSucceed(object sender, HttpFactoryArgs <PPTVData.Entity.PlayInfo> args) { PPTVData.Entity.PlayInfo.Item item = args.Result.GetItemByFileType(5); if (item == null) { return; } _rid = item.Rid; if (item.DtInfo != null) { DownPage.UpdateTask(_vid, item.url); } else { string jump_url = "http://wp7.jump.synacast.com/" + item.Rid + "dt?type=mwp7"; PPTVData.HttpWebClient jumpWebClient = new PPTVData.HttpWebClient(); jumpWebClient.DownloadStringCompleted += new PPTVData.DownloadStringCompletedEventHandler(JumpWebClientDownloadStringCompleted); jumpWebClient.DownloadStringAsync(jump_url); } }
private void StartDownloadProgram() { if (!detailDownloaded) { return; } if (_downSign != null) { _downSign.Foreground = App.Current.Resources["Orange"] as SolidColorBrush;; if (_piForDownload != null) { _piForDownload.IsDown = Visibility.Visible; } Utils.CustomAnimation.DownloadAnimation(xDownAnima); if (DownPage.AddTask(DetailPageHelp.ChannelDetailInfoForPrograms, _piForDownload) == false) { return; } } PlayInfoFactory playFac = new PlayInfoFactory(); if (_piForDownload != null) { playFac.HttpSucessHandler += playFac_GetPlayInfoSucceed; playFac.HttpFailHandler += playFac_GetPlayInfoFailed; playFac.HttpTimeOutHandler += playFac_GetPlayInfoTimeout; _downProgramInfo.Add(playFac, _piForDownload); playFac.DownLoadDatas(_piForDownload.ChannelVID); } else { playFac.HttpSucessHandler += playFac_GetPlayInfoSucceed; playFac.HttpFailHandler += playFac_GetPlayInfoFailed; playFac.HttpTimeOutHandler += playFac_GetPlayInfoTimeout; _downProgramInfo.Add(playFac, _piForDownload); playFac.DownLoadDatas(DetailPageHelp.ChannelDetailInfoForPrograms.VID); } }
public DownPage() { InitializeComponent(); _instance = this; }