public static void LoadChannelList() { bool IsLoaded = false; System.Diagnostics.Debug.WriteLine("LoadChannelList url:" + CommonData.VideoListUrl); httpGet(CommonData.VideoListUrl, (ar) => { string result = HttpHelper.SyncResultTostring(ar); if (result != null) { ChannelsResult channels = null; try { channels = JsonConvert.DeserializeObject <ChannelsResult>(result); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("LoadChannelCompleted json 解析错误" + ex.Message); App.JsonError(result); } if (channels != null && channels.err_code == rightCode) { CommonData.LockedChannel = channels.data.lockedChannel; CommonData.NormalChannel = channels.data.normalChannel; IsLoaded = true; WpStorage.SaveStringToIsoStore(CommonData.ChannelStorage, JsonConvert.SerializeObject(channels.data)); CommonData.ChannelLoaded = true; } } //CommonData.informCallback((int)CommonData.CallbackType.LoadedData, IsLoaded); }); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); CallbackManager.currentPage = this; this.DataContext = App.PlayerModel; if (App.PlayerModel.MediaSource != null) { App.PlayerModel.MediaSource = App.PlayerModel.MediaSource; myMediaElement.Tap += new EventHandler <System.Windows.Input.GestureEventArgs>(myMediaElement_Tap); } if (App.PlayerModel.currentType == PlayerViewModel.PlayType.LoaclType) { ////处理正在播放本地视频时切换应用或返回主页问题 if (WpStorage.GetIsoSetting(needSetSliderValueIso) != null) { needSetSliderValue = (bool)WpStorage.GetIsoSetting(needSetSliderValueIso); if (needSetSliderValue) { LoadLocalVideoList(); } } } else { LoadDramaSeletedItem(App.PlayerModel.VideoId); } App.ShowLoading(); App.PlayerModel.LoadVisibility = Visibility.Visible; App.PlayerModel.PayVisibility = Visibility.Collapsed; }
protected override void OnNavigatedFrom(NavigationEventArgs e) { base.OnNavigatedFrom(e); CallbackManager.currentPage = null; currentPosition.Stop(); //当用户按win键 或者长按返回键时 不清空 datacontext 否则从墓碑模式返回时会丢失当前数据 if (e.Content != null) { //如果不是返回下载页 if (!(e.Content is DownVideo)) { leaveSilderValue = pbVideo.Value; App.PlayerModel.ClearData(); this.DataContext = null; } } else { needSetSliderValue = true; GC.Collect(); GC.WaitForPendingFinalizers(); } myMediaElement.Tap -= myMediaElement_Tap; App.HideLoading(); WpStorage.SetIsoSetting(needSetSliderValueIso, needSetSliderValue); WpStorage.SetIsoSetting(leaveSilderValueIso, leaveSilderValue); }
//视频状态改变时的处理事件 void myMediaElement_CurrentStateChanged(object sender, RoutedEventArgs e) { if (myMediaElement.CurrentState == MediaElementState.Playing) {//播放视频时各菜单的状态 if (WpStorage.GetIsoSetting(needSetSliderValueIso) != null) { needSetSliderValue = (bool)WpStorage.GetIsoSetting(needSetSliderValueIso); if (needSetSliderValue) { needSetSliderValue = false; WpStorage.SetIsoSetting(needSetSliderValueIso, needSetSliderValue); if (WpStorage.GetIsoSetting(leaveSilderValueIso) != null) { leaveSilderValue = (double)WpStorage.GetIsoSetting(leaveSilderValueIso); pbVideo.Tag = "isFoucesed"; pbVideo.Value = leaveSilderValue; } } } //更换清晰度 if (App.PlayerModel.IsChangeDefinition) { pbVideo.Tag = "isFoucesed"; pbVideo.Value = leaveSilderValue; //myMediaElement.Position = new TimeSpan(0, 0, 0, (int)leaveSilderValue); } currentPosition.Start(); App.HideLoading(); App.PlayerModel.LoadVisibility = Visibility.Collapsed; PlayImg.Source = new BitmapImage(new Uri(pauseImg, UriKind.RelativeOrAbsolute)); } else if (myMediaElement.CurrentState == MediaElementState.Paused) { //暂停视频时各菜单的状态 currentPosition.Stop(); PlayImg.Source = new BitmapImage(new Uri(playImg, UriKind.RelativeOrAbsolute)); } else {//停止视频时各菜单的状态 currentPosition.Stop(); PlayImg.Source = new BitmapImage(new Uri(playImg, UriKind.RelativeOrAbsolute)); //NextPlayerGrid_Tap(null,null); } }