/// <summary> /// Initializes a new instance of the PlaylistViewModel class. /// </summary> public NowPlayingViewModel(INavigationService navigationService, IConnectionManager connectionManager, IStorageService storageService) :base (navigationService, connectionManager) { _playlistChecker = new DispatcherTimer { Interval = new TimeSpan(0, 0, 3) }; _playlistChecker.Tick += PlaylistCheckerOnTick; Playlist = new ObservableCollection<PlaylistItem>(); SelectedItems = new List<PlaylistItem>(); if (IsInDesignMode) { Playlist = new ObservableCollection<PlaylistItem> { new PlaylistItem {Artist = "John Williams", Album = "Jurassic Park OST", Id = 1, IsPlaying = true, TrackName = "Jurassic Park Theme"}, new PlaylistItem {Artist = "John Williams", Album = "Jurassic Park OST", Id = 2, IsPlaying = false, TrackName = "Journey to the Island"}, new PlaylistItem {Artist = "John Williams", Album = "Jurassic Park OST", Id = 10, IsPlaying = false, TrackName = "Incident at Isla Nublar"} }; NowPlayingItem = Playlist[0]; } else { _playlistHelper = new PlaylistHelper(storageService); BackgroundAudioPlayer.Instance.PlayStateChanged += OnPlayStateChanged; GetPlaylistItems(); IsPlaying = BackgroundAudioPlayer.Instance.PlayerState == PlayState.Playing; } }
/// <remarks> /// AudioPlayer instances can share the same process. /// Static fields can be used to share state between AudioPlayer instances /// or to communicate with the Audio Streaming agent. /// </remarks> public AudioPlayer() { _playlistHelper = new PlaylistHelper(new StorageService()); if (!_classInitialized) { _classInitialized = true; // Subscribe to the managed exception handler Deployment.Current.Dispatcher.BeginInvoke(delegate { Application.Current.UnhandledException += AudioPlayer_UnhandledException; }); } }
/// <remarks> /// AudioPlayer instances can share the same process. /// Static fields can be used to share state between AudioPlayer instances /// or to communicate with the Audio Streaming agent. /// </remarks> public AudioPlayer() { _playlistHelper = new PlaylistHelper(new StorageService()); if (!_classInitialized) { _classInitialized = true; // Subscribe to the managed exception handler Deployment.Current.Dispatcher.BeginInvoke(delegate { Application.Current.UnhandledException += AudioPlayer_UnhandledException; }); } }