private async void Scenario1_Loaded(object sender, RoutedEventArgs e) { Debug.WriteLine("Scenario1_Loaded"); // Update controls according to settings UpdateControlVisibility(); SettingsService.Instance.UseCustomControlsChanged += SettingsService_UseCustomControlsChanged; // Bind player to element mediaPlayerElement.SetMediaPlayer(Player); // Load the playlist data model if needed if (MediaList == null) { // Create the playlist data model MediaList = new MediaList(); await MediaList.LoadFromApplicationUriAsync("ms-appx:///Assets/playlist.json"); } // Create a new playback list matching the data model if one does not exist if (PlaybackList == null) { PlaybackList = MediaList.ToPlaybackList(); } // Subscribe to playback list item failure events PlaybackList.ItemFailed += PlaybackList_ItemFailed; // Create the view model list from the data model and playback model // and assign it to the player PlayerViewModel.MediaList = new MediaListViewModel(MediaList, PlaybackList, Dispatcher); }
private async void CurrentPlayingBar_Loaded(object sender, RoutedEventArgs e) { // Bind player to element mediaPlayerElement.SetMediaPlayer(Player); // Load the playlist data model if needed if (MediaList == null) { // Create the playlist data model MediaList = new MediaList(); try { await MediaList.LoadFromApplicationUriAsync("ms-appx:///Assets/Data/playlist.json"); } catch (Exception ex) { var toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02); var toastTextElements = toastXml.GetElementsByTagName("text"); toastTextElements[0].AppendChild(toastXml.CreateTextNode("Exception")); toastTextElements[1].AppendChild(toastXml.CreateTextNode(ex.Message)); var toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(toast); } } // Create a new playback list matching the data model if one does not exist if (PlaybackList == null) { PlaybackList = MediaList.ToPlaybackList(); } // Subscribe to playback list item failure events PlaybackList.ItemFailed += PlaybackList_ItemFailed; // Create the view model list from the data model and playback model // and assign it to the player PlayerViewModel.MediaList = new MediaListViewModel(MediaList, PlaybackList, Dispatcher); }
private async void Scenario1_Loaded(object sender, RoutedEventArgs e) { Debug.WriteLine("Scenario1_Loaded"); // Update controls according to settings UpdateControlVisibility(); SettingsService.Instance.UseCustomControlsChanged += SettingsService_UseCustomControlsChanged; // Bind player to element mediaPlayerElement.SetMediaPlayer(Player); // Load the playlist data model if needed if (MediaList == null) { // Create the playlist data model MediaList = new MediaList(); await MediaList.LoadFromApplicationUriAsync("ms-appx:///Assets/playlist.json"); } // Create a new playback list matching the data model if one does not exist if (PlaybackList == null) PlaybackList = MediaList.ToPlaybackList(); // Subscribe to playback list item failure events PlaybackList.ItemFailed += PlaybackList_ItemFailed; // Create the view model list from the data model and playback model // and assign it to the player PlayerViewModel.MediaList = new MediaListViewModel(MediaList, PlaybackList, Dispatcher); }