public PlayControlViewModel(MainViewModel mainViewModel) { var container = TinyIoCContainer.Current; this.playListsViewModel = mainViewModel.PlayListsViewModel; this.PlayerEngine = container.Resolve <PlayerEngine>(); this.PlayerSettings = container.Resolve <PlayerSettings>(); this.PlayerEngine.PlayNextFileAction = () => { var playerMustBeStoped = !this.CanPlayNext(); if (!playerMustBeStoped) { playerMustBeStoped = !this.PlayerSettings.PlayerEngine.ShuffleMode && !this.PlayerSettings.PlayerEngine.RepeatMode && this.playListsViewModel.IsLastPlayListFile(); if (!playerMustBeStoped) { this.PlayNext(); } } if (playerMustBeStoped) { this.Stop(); } }; this.PlayOrPauseCommand = new DelegateCommand(this.PlayOrPause, this.CanPlayOrPause); this.StopCommand = new DelegateCommand(this.Stop, this.CanStop); this.PlayPrevCommand = new DelegateCommand(this.PlayPrev, this.CanPlayPrev); this.PlayNextCommand = new DelegateCommand(this.PlayNext, this.CanPlayNext); var playerInitialized = this.WhenAnyValue(x => x.PlayerEngine.Initializied); this.ShuffleCommand = ReactiveCommand.Create( () => this.PlayerSettings.PlayerEngine.ShuffleMode = !this.PlayerSettings.PlayerEngine.ShuffleMode, playerInitialized); this.RepeatCommand = ReactiveCommand.Create( () => this.PlayerSettings.PlayerEngine.RepeatMode = !this.PlayerSettings.PlayerEngine.RepeatMode, playerInitialized); this.MuteCommand = ReactiveCommand.Create( () => this.PlayerEngine.IsMute = !this.PlayerEngine.IsMute, playerInitialized); this.ShowMediaLibraryCommand = ReactiveCommand.Create( () => this.ShowMediaLibrary(), playerInitialized); this.ShowEqualizerCommand = ReactiveCommand.CreateFromTask( () => this.ShowEqualizer(), this.WhenAnyValue(x => x.IsEqualizerOpen, x => x.PlayerEngine.Initializied, (isopen, initialized) => !isopen && initialized)); }
public PlayControlViewModel(MainViewModel mainViewModel) { var container = TinyIoCContainer.Current; this.playListsViewModel = mainViewModel.PlayListsViewModel; this.PlayerEngine = container.Resolve <PlayerEngine>(); this.PlayerSettings = container.Resolve <PlayerSettings>(); this.PlayerEngine.PlayNextFileAction = () => { var playerMustBeStoped = !this.CanPlayNext(); if (!playerMustBeStoped) { playerMustBeStoped = !this.PlayerSettings.PlayerEngine.ShuffleMode && !this.PlayerSettings.PlayerEngine.RepeatMode && this.playListsViewModel.IsLastPlayListFile(); if (!playerMustBeStoped) { this.PlayNext(); } } if (playerMustBeStoped) { this.Stop(); } }; var playerInitialized = this.WhenAnyValue(x => x.PlayerEngine.Initializied); this.ShuffleCommand = ReactiveCommand.Create(playerInitialized); this.ShuffleCommand.Subscribe(x => { this.PlayerSettings.PlayerEngine.ShuffleMode = !this.PlayerSettings.PlayerEngine.ShuffleMode; }); this.RepeatCommand = ReactiveCommand.Create(playerInitialized); this.RepeatCommand.Subscribe(x => { this.PlayerSettings.PlayerEngine.RepeatMode = !this.PlayerSettings.PlayerEngine.RepeatMode; }); this.MuteCommand = ReactiveCommand.Create(playerInitialized); this.MuteCommand.Subscribe(x => { this.PlayerEngine.IsMute = !this.PlayerEngine.IsMute; }); this.ShowMediaLibraryCommand = ReactiveCommand.Create(playerInitialized); this.ShowEqualizerCommand = ReactiveCommand.CreateAsyncTask(this.WhenAnyValue(x => x.IsEqualizerOpen, x => x.PlayerEngine.Initializied, (isopen, initialized) => !isopen && initialized), x => ShowEqualizer()); }
public PlayControlViewModel(MainViewModel mainViewModel) { var container = TinyIoCContainer.Current; this.playListsViewModel = mainViewModel.PlayListsViewModel; this.PlayerEngine = container.Resolve<PlayerEngine>(); this.PlayerSettings = container.Resolve<PlayerSettings>(); this.PlayerEngine.PlayNextFileAction = () => { var playerMustBeStoped = !this.CanPlayNext(); if (!playerMustBeStoped) { playerMustBeStoped = !this.PlayerSettings.PlayerEngine.ShuffleMode && !this.PlayerSettings.PlayerEngine.RepeatMode && this.playListsViewModel.IsLastPlayListFile(); if (!playerMustBeStoped) { this.PlayNext(); } } if (playerMustBeStoped) { this.Stop(); } }; var playerInitialized = this.WhenAnyValue(x => x.PlayerEngine.Initializied); this.ShuffleCommand = ReactiveCommand.Create(playerInitialized); this.ShuffleCommand.Subscribe(x => { this.PlayerSettings.PlayerEngine.ShuffleMode = !this.PlayerSettings.PlayerEngine.ShuffleMode; }); this.RepeatCommand = ReactiveCommand.Create(playerInitialized); this.RepeatCommand.Subscribe(x => { this.PlayerSettings.PlayerEngine.RepeatMode = !this.PlayerSettings.PlayerEngine.RepeatMode; }); this.MuteCommand = ReactiveCommand.Create(playerInitialized); this.MuteCommand.Subscribe(x => { this.PlayerEngine.IsMute = !this.PlayerEngine.IsMute; }); this.ShowMediaLibraryCommand = ReactiveCommand.Create(playerInitialized); this.ShowEqualizerCommand = ReactiveCommand.CreateAsyncTask(this.WhenAnyValue(x => x.IsEqualizerOpen, x => x.PlayerEngine.Initializied, (isopen, initialized) => !isopen && initialized), x => ShowEqualizer()); }