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 PlayControlInfoViewModel(MainViewModel mainViewModel) { this.PlayControlViewModel = new PlayControlViewModel(mainViewModel); }