private void xMedia_MediaFailed(object sender, ExceptionRoutedEventArgs e) { try { xMedia.Stop(); if (MediaFailed != null) { PPLiveExceptionRoutedEventArgs args = new PPLiveExceptionRoutedEventArgs(this, e.ErrorException); MediaFailed(this, args); } if (sender == null) { Output("xMedia_MediaFailed sender==null"); return; } if (e == null) { Output("xMedia_MediaFailed e==null"); return; } xMediaStatusTextBlockA.Text = "视频文件播放失败"; } catch (Exception exp) { Output(exp.ToString()); } }
void _jump_webclient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error == null) { Output("成功获得jump文件 " + e.Result); Output("解析xml"); try { using (XmlReader reader = XmlReader.Create(new StringReader(e.Result))) { if (true == reader.ReadToFollowing("server_host")) { string server_host = reader.ReadElementContentAsString("server_host", ""); _media_server_host = server_host; Output("server_host=" + server_host); } else { // } reader.ReadToFollowing("server_time"); string server_time = reader.ReadElementContentAsString("server_time", ""); Output("server_time=" + server_time); CultureInfo ci = new CultureInfo("en-US"); _server_base_time = DateTime.ParseExact(server_time, "ddd MMM dd HH:mm:ss yyyy UTC", ci); _local_base_time = DateTime.Now; Output("_server_base_time=" + _server_base_time); _playDecodeUrl = "http://" + _media_server_host + ":80/" + _playInfo.Rid + "?type=wp7&w=1&key=" + GetServerRelativeTimeString(); Dispatcher.BeginInvoke(() => { xMedia.Source = new Uri(_playDecodeUrl, UriKind.Absolute); }); Output("播放地址:" + _playDecodeUrl); } } catch (Exception exp) { Output("jump_webclient_DownloadStringCompleted " + exp.ToString()); if (MediaFailed != null) { PPLiveExceptionRoutedEventArgs args = new PPLiveExceptionRoutedEventArgs(this, new PPLiveOpenException("获得jump文件失败 " + exp.Message)); MediaFailed(this, args); } } } else { Output("获得jump文件失败 " + e.Error.ToString()); if (MediaFailed != null) { PPLiveExceptionRoutedEventArgs args = new PPLiveExceptionRoutedEventArgs(this, new PPLiveOpenException("获得jump文件失败 " + e.Error.Message)); MediaFailed(this, args); } } }