protected async override void OnNavigatedTo(NavigationEventArgs e) { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; SystemNavigationManager.GetForCurrentView().BackRequested += NewsElement_BackRequested; DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait | DisplayOrientations.Landscape | DisplayOrientations.LandscapeFlipped; //ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); //NetworkConnectivityLevel connection = InternetConnectionProfile.GetNetworkConnectivityLevel(); //bool internetAccess = !(connection == NetworkConnectivityLevel.None || connection == NetworkConnectivityLevel.LocalAccess); bool internetAccess = NetworkInterface.GetIsNetworkAvailable(); if (internetAccess && e.Parameter != null) { DisplayInformation.GetForCurrentView().OrientationChanged += NewsElement_OrientationChanged; string[] param = (string[])e.Parameter; HeaderNews.Text = param[0]; DateNews.Text = param[1]; OneNewsModel oneNews = await NewsElementParser.Parse(param[2]); DescrNews.Text = oneNews.Description; YouTubeQuality quality = YouTubeQuality.Quality360P; if (Settings.Settings.QualityYouTubeVideo != null) { switch (Settings.Settings.QualityYouTubeVideo) { case "360p": quality = YouTubeQuality.Quality360P; break; case "480p": quality = YouTubeQuality.Quality480P; break; case "720p": quality = YouTubeQuality.Quality720P; break; case "1080p": quality = YouTubeQuality.Quality1080P; break; } } YouTubeUri videoUri = null; bool error = false; try { videoUri = await YouTube.GetVideoUriAsync(oneNews.YouTubeID, quality); } catch (YouTubeUriNotFoundException) { error = true; } if (!error && videoUri != null) { playerYouTube.MediaPlayer.SetUriSource(videoUri.Uri); } else { var dialog = new MessageDialog("Не удалось загрузить видео."); await dialog.ShowAsync(); Frame.GoBack(); } } else { var dialog = new MessageDialog("Проверьте соединение с интернетом"); await dialog.ShowAsync(); Frame.GoBack(); } }
public async void LoadNews(string htmlUrl) { OneNews = await NewsElementParser.Parse(htmlUrl); }
/// <summary> /// Вызывается перед отображением этой страницы во фрейме. /// </summary> /// <param name="e">Данные события, описывающие, каким образом была достигнута эта страница. /// Этот параметр обычно используется для настройки страницы.</param> protected async override void OnNavigatedTo(NavigationEventArgs e) { DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait | DisplayOrientations.Landscape | DisplayOrientations.LandscapeFlipped; if (e.Parameter != null) { DisplayInformation.DisplayContentsInvalidated += DisplayInformation_DisplayContentsInvalidated; string[] param = (string[])e.Parameter; HeaderNews.Text = param[0]; DateNews.Text = param[1]; OneNews oneNews = await NewsElementParser.Parse(param[2]); DescrNews.Text = oneNews.Description; YouTubeQuality quality = YouTubeQuality.Quality360P; if (Settings.Settings.QualityYouTubeVideo != null) { switch (Settings.Settings.QualityYouTubeVideo) { case "144p": quality = YouTubeQuality.Quality144P; break; case "240p": quality = YouTubeQuality.Quality240P; break; case "360p": quality = YouTubeQuality.Quality360P; break; case "480p": quality = YouTubeQuality.Quality480P; break; case "720p": quality = YouTubeQuality.Quality720P; break; case "1080p": quality = YouTubeQuality.Quality1080P; break; } } YouTubeUri videoUri = null; bool error = false; try { videoUri = await YouTube.GetVideoUriAsync(oneNews.YouTubeID, quality); } catch (YouTubeUriNotFoundException) { error = true; } if (!error && videoUri != null) { playerYouTube.Source = videoUri.Uri; } else { var dialog = new MessageDialog("Не удалось загрузить видео. \nПопробуйте поменять качество в настройках."); await dialog.ShowAsync(); } } else { if (Frame.CanGoBack) { Frame.GoBack(); } } }