public DiscChangerViewModel(DiscChanger discChanger) { _discChanger = discChanger; _isPaused = _discChanger.WhenAnyValue(x => x.IsPaused) .ToProperty(this, nameof(IsPaused)); PlayCommand = ReactiveCommand.CreateFromTask(async() => { await _discChanger.Play(); }); ForwardCommand = ReactiveCommand.CreateFromTask(async() => { await _discChanger.Forward(); }); BackCommand = ReactiveCommand.CreateFromTask(async() => { await _discChanger.Back(); }); }
public DiscChangerViewModel(DiscChanger discChanger) { _discChanger = discChanger; _isPlaying = _discChanger.WhenAnyValue(x => x.IsPlaying) .ToProperty(this, nameof(IsPlaying)); PlayCommand = ReactiveCommand.Create(() => { if (_discChanger.IsPlaying) { _discChanger.Pause(); } else { _discChanger.Play(); } }); ForwardCommand = ReactiveCommand.Create(_discChanger.Forward); BackCommand = ReactiveCommand.Create(_discChanger.Back); }