public PlaybarViewModel(IEventAggregator eventAggregator, IDataService dataService, IHotKeyService hotKeyService, IMusicPlayerService musicPlayerService) { _dataService = dataService; _musicPlayerService = musicPlayerService; eventAggregator.Subscribe(this); _musicPlayerService.ProgressUpdated += (sender, e) => { if (_syncPlayer) { _currentProgress = e.NewProgress; NotifyOfPropertyChange(nameof(CurrentProgress)); } ActivePlaylist.Playlist.TrackProgress = e.NewProgress; }; _musicPlayerService.TrackChanged += (sender, e) => NotifyOfPropertyChange(nameof(Duration)); _musicPlayerService.Paused += (sender, e) => NotifyOfPropertyChange(nameof(Playing)); _musicPlayerService.Played += (sender, e) => NotifyOfPropertyChange(nameof(Playing)); _musicPlayerService.MediaEnded += (sender, e) => { if (Loop) { _musicPlayerService.Stop(); _musicPlayerService.Play(); } else { ActivePlaylist.SelectNext(); } }; hotKeyService.HotKeyActuated += (sender, e) => { switch (e.Shortcut) { case Shortcut.SkipBackward: Previous(); break; case Shortcut.SkipForward: Next(); break; } }; PlaybarState playbarState = dataService.Load(Constants.DataStoreNames.PlaybarState, () => new PlaybarState(0.5, false)); Volume = playbarState.Volume; Loop = playbarState.Loop; }
public void StopRecord() { _animation.Stop(); _musicPlayerService.Stop(); }