Exemplo n.º 1
0
        /// <summary>
        /// 暂停录制
        /// </summary>
        public void OnRecordPause()
        {
            if (_timerModel.Waiting == false && _recordingModel.RecorderState != Models.RecorderState.NotRecording)
            {
                _audioPlayer.Play(SoundKind.Pause);

                _recordingModel.OnPauseExecute();
            }
        }
Exemplo n.º 2
0
        public RecordingViewModel(RecordingModel RecordingModel,
                                  Settings Settings,
                                  TimerModel TimerModel,
                                  WebcamModel WebcamModel,
                                  VideoSourcesViewModel VideoSourcesViewModel,
                                  VideoWritersViewModel VideoWritersViewModel,
                                  ISystemTray SystemTray,
                                  IMainWindow MainWindow,
                                  ILocalizationProvider Loc,
                                  IAudioPlayer AudioPlayer,
                                  IRecentList RecentList,
                                  IMessageProvider MessageProvider,
                                  AudioSourceViewModel AudioSourceViewModel,
                                  IFFmpegViewsProvider FFmpegViewsProvider) : base(Settings, Loc)
        {
            _recordingModel        = RecordingModel;
            _timerModel            = TimerModel;
            _videoSourcesViewModel = VideoSourcesViewModel;
            _videoWritersViewModel = VideoWritersViewModel;
            _systemTray            = SystemTray;
            _mainWindow            = MainWindow;
            _audioPlayer           = AudioPlayer;
            _recentList            = RecentList;
            _messageProvider       = MessageProvider;
            _audioSourceViewModel  = AudioSourceViewModel;
            _ffmpegViewsProvider   = FFmpegViewsProvider;

            var hasAudio = new[]
            {
                Settings
                .Audio
                .ObserveProperty(M => M.RecordMicrophone),
                Settings
                .Audio
                .ObserveProperty(M => M.RecordSpeaker)
            }
            .CombineLatest(M => M[0] || M[1]);

            RecordCommand = new[]
            {
                hasAudio,
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is NoVideoSourceProvider),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is WebcamSourceProvider),
                WebcamModel
                .ObserveProperty(M => M.SelectedCam)
                .Select(M => M is NoWebcamItem),
                Settings
                .Video
                .ObserveProperty(M => M.RecorderMode)
                .Select(M => M == RecorderMode.Steps),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M.SupportsStepsMode),
            }
            .CombineLatest(M =>
            {
                var audioEnabled      = M[0];
                var audioOnlyMode     = M[1];
                var webcamMode        = M[2];
                var noWebcam          = M[3];
                var stepsMode         = M[4];
                var supportsStepsMode = M[5];

                if (stepsMode)
                {
                    return(supportsStepsMode);
                }

                if (audioOnlyMode)
                {
                    return(audioEnabled);
                }

                if (webcamMode)
                {
                    return(!noWebcam);
                }

                return(true);
            })
            .ToReactiveCommand()
            .WithSubscribe(OnRecordExecute);

            PauseCommand = new[]
            {
                TimerModel
                .ObserveProperty(M => M.Waiting),
                RecordingModel
                .ObserveProperty(M => M.RecorderState)
                .Select(M => M != Models.RecorderState.NotRecording)
            }
            .CombineLatest(M => !M[0] && M[1])
            .ToReactiveCommand()
            .WithSubscribe(() =>
            {
                _audioPlayer.Play(SoundKind.Pause);

                RecordingModel.OnPauseExecute();
            });

            RecorderState = RecordingModel
                            .ObserveProperty(M => M.RecorderState)
                            .ToReadOnlyReactivePropertySlim();

            TimerModel.DurationElapsed += () =>
            {
                _syncContext.Run(async() => await StopRecording(), true);
            };
        }
Exemplo n.º 3
0
        public RecordingViewModel(RecordingModel RecordingModel,
                                  Settings Settings,
                                  TimerModel TimerModel,
                                  WebcamModel WebcamModel,
                                  VideoSourcesViewModel VideoSourcesViewModel,
                                  VideoWritersViewModel VideoWritersViewModel,
                                  ISystemTray SystemTray,
                                  IMainWindow MainWindow,
                                  ILocalizationProvider Loc,
                                  IAudioPlayer AudioPlayer,
                                  IRecentList RecentList,
                                  IMessageProvider MessageProvider) : base(Settings, Loc)
        {
            _recordingModel        = RecordingModel;
            _timerModel            = TimerModel;
            _videoSourcesViewModel = VideoSourcesViewModel;
            _videoWritersViewModel = VideoWritersViewModel;
            _systemTray            = SystemTray;
            _mainWindow            = MainWindow;
            _audioPlayer           = AudioPlayer;
            _recentList            = RecentList;
            _messageProvider       = MessageProvider;

            RecordCommand = new[]
            {
                Settings.Audio
                .ObserveProperty(M => M.Enabled),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is NoVideoSourceProvider),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is WebcamSourceProvider),
                WebcamModel
                .ObserveProperty(M => M.SelectedCam)
                .Select(M => M is NoWebcamItem)
            }
            .CombineLatest(M =>
            {
                var audioEnabled  = M[0];
                var audioOnlyMode = M[1];
                var webcamMode    = M[2];
                var noWebcam      = M[3];

                if (audioOnlyMode)
                {
                    return(audioEnabled);
                }

                if (webcamMode)
                {
                    return(!noWebcam);
                }

                return(true);
            })
            .ToReactiveCommand()
            .WithSubscribe(OnRecordExecute);

            PauseCommand = new[]
            {
                TimerModel
                .ObserveProperty(M => M.Waiting),
                RecordingModel
                .ObserveProperty(M => M.RecorderState)
                .Select(M => M != Models.RecorderState.NotRecording)
            }
            .CombineLatest(M => !M[0] && M[1])
            .ToReactiveCommand()
            .WithSubscribe(() =>
            {
                _audioPlayer.Play(SoundKind.Pause);

                RecordingModel.OnPauseExecute();
            });

            RecorderState = RecordingModel
                            .ObserveProperty(M => M.RecorderState)
                            .ToReadOnlyReactivePropertySlim();

            TimerModel.DurationElapsed += async() =>
            {
                if (_syncContext != null)
                {
                    _syncContext.Post(async State => await StopRecording(), null);
                }
                else
                {
                    await StopRecording();
                }
            };
        }
Exemplo n.º 4
0
 public void OnPauseExecuteEx()
 {
     _recordingModel.OnPauseExecute();
 }
Exemplo n.º 5
0
        public RecordingViewModel(RecordingModel RecordingModel,
                                  Settings Settings,
                                  TimerModel TimerModel,
                                  WebcamModel WebcamModel,
                                  VideoSourcesViewModel VideoSourcesViewModel,
                                  ISystemTray SystemTray,
                                  IMainWindow MainWindow,
                                  ILocalizationProvider Loc,
                                  IAudioPlayer AudioPlayer) : base(Settings, Loc)
        {
            _recordingModel = RecordingModel;
            _systemTray     = SystemTray;
            _mainWindow     = MainWindow;
            _audioPlayer    = AudioPlayer;

            RecordCommand = new[]
            {
                Settings.Audio
                .ObserveProperty(M => M.Enabled),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is NoVideoSourceProvider),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is WebcamSourceProvider),
                WebcamModel
                .ObserveProperty(M => M.SelectedCam)
                .Select(M => M is NoWebcamItem)
            }
            .CombineLatest(M =>
            {
                var audioEnabled  = M[0];
                var audioOnlyMode = M[1];
                var webcamMode    = M[2];
                var noWebcam      = M[3];

                if (audioOnlyMode)
                {
                    return(audioEnabled);
                }

                if (webcamMode)
                {
                    return(!noWebcam);
                }

                return(true);
            })
            .ToReactiveCommand()
            .WithSubscribe(OnRecordExecute);

            PauseCommand = new[]
            {
                TimerModel
                .ObserveProperty(M => M.Waiting),
                RecordingModel
                .ObserveProperty(M => M.RecorderState)
                .Select(M => M != Models.RecorderState.NotRecording)
            }
            .CombineLatest(M => !M[0] && M[1])
            .ToReactiveCommand()
            .WithSubscribe(() =>
            {
                _audioPlayer.Play(SoundKind.Pause);

                RecordingModel.OnPauseExecute();
            });

            RecorderState = RecordingModel
                            .ObserveProperty(M => M.RecorderState)
                            .ToReadOnlyReactivePropertySlim();
        }