public BlotifyViewModel(SpotifyClient spotify) { this.spotify = spotify; PlayCommand = ReactiveCommand.Create(PlayPause, spotify.CanPlay); PreviousCommand = ReactiveCommand.Create(spotify.Previous, spotify.CanPrevious); NextCommand = ReactiveCommand.Create(spotify.Next, spotify.CanSkip); ToggleDetails = ReactiveCommand.Create(() => ShowDetails = !ShowDetails, Observable.Return(true)); disposable = new CompositeDisposable( spotify.TrackChanged.ObserveOn(Dispatcher.CurrentDispatcher).Where(track => track != null).Subscribe(track => CurrentTrack = new CurrentTrack(track)), spotify.TimeChanged.ObserveOn(Dispatcher.CurrentDispatcher).Subscribe(time => CurrentTime = time), spotify.IsPlaying.ObserveOn(Dispatcher.CurrentDispatcher).Subscribe(v => IsPlaying = v), PlayCommand, PreviousCommand, NextCommand, ToggleDetails, spotify, PlayCommand, PreviousCommand, NextCommand); spotify.Connect(); }
private void App_OnStartup(object sender, StartupEventArgs e) { var spotify = new SpotifyClient(); try { spotify.Connect(); new MainWindow { DataContext = new BlotifyViewModel(spotify) }.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); Shutdown(); } }