Пример #1
0
        /// ------------------------------------------------------------------------------------
        public void Pause()
        {
            if (!PlaybackInProgress)
            {
                return;
            }

            DisableTimer();
            //_paused = !_paused;
            PlayerViewModel.Pause();
        }
Пример #2
0
        public PlayerViewController(PlayerViewModel viewModel)
        {
            View = new PlayerView();

            viewModel.WhenAnyValue(vm => vm.CurrentTrack)
            .Where(track => track != null)
            .Subscribe(track => UpdateTrackInformation(track));

            viewModel.WhenAnyValue(vm => vm.CurrentTrack)
            .Select(track => track != null)
            .BindTo(View.PlayerControls.PlayButton, button => button.Enabled);

            viewModel.WhenAnyValue(vm => vm.Playing)
            .Subscribe(playing => {
                if (playing)
                {
                    View.PlayerControls.ShowPauseButton();
                }
                else
                {
                    View.PlayerControls.ShowPlayButton();
                }
            });

            var mutedObservable = viewModel.WhenAnyValue(vm => vm.Muted);

            viewModel.WhenAnyValue(vm => vm.Volume)
            .CombineLatest(mutedObservable, (volume, muted) => muted ? 0.0f : volume)
            .BindTo(View.SoundControl.VolumeSlider, slider => slider.FloatValue);

            mutedObservable.BindTo(View.SoundControl, sc => sc.Muted);

            View.PlayerControls.PlayButton.Activated  += (sender, e) => viewModel.Play(viewModel.CurrentTrack);
            View.PlayerControls.PauseButton.Activated += (sender, e) => viewModel.Pause();
            View.SoundControl.VolumeSlider.Activated  += (sender, e) => viewModel.Volume = (sender as NSSlider).FloatValue;
            View.SoundControl.MuteButton.Activated    += (sender, e) => viewModel.ToggleMute();

            var progressObservable = View.Progress
                                     .WhenAnyValue(p => p.Progress);

            progressObservable
            .Where(_ => !View.Progress.IsDragging)
            .BindTo(viewModel, vm => vm.Progress);

            progressObservable
            .Where(_ => View.Progress.IsDragging)
            .Throttle(TimeSpan.FromMilliseconds(100), RxApp.MainThreadScheduler)
            .Subscribe(progress => viewModel.Seek(progress));

            viewModel.WhenAnyValue(vm => vm.Progress)
            .Where(_ => !View.Progress.IsDragging)
            .DistinctUntilChanged()
            .Subscribe(progress => View.Progress.Progress = progress);
        }
Пример #3
0
 /// <summary>
 /// The function pauses the simualtor on pause button click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Pause_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     viewModel.Pause();
 }