示例#1
0
        public bool QueueAudioPlayback(string fileName = null, string startIndicatorFileName = null, string endIndicatorFileName = null)
        {
            bool   replayFileExists = false;
            string fileNameToPlay;

            if (fileName == null)
            {
                replayFileExists = selectedFileService.SelectedFile.Exists;
                fileNameToPlay   = selectedFileService.SelectedFile.FullName;
            }
            else
            {
                var fileInfo = new FileInfo(fileName);
                replayFileExists = fileInfo.Exists;
                fileNameToPlay   = fileName;
            }

            if (!replayFileExists)
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(startIndicatorFileName))
            {
                audioPlaybackService.QueueFile(startIndicatorFileName);
            }

            audioPlaybackService.QueueFile(fileNameToPlay);

            if (!string.IsNullOrEmpty(endIndicatorFileName))
            {
                audioPlaybackService.QueueFile(endIndicatorFileName);
            }

            return(true);
        }
示例#2
0
        private void AudioRecordingService_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case nameof(AudioRecordingService.CurrentlyRecording):
            {
                if (AudioRecordingService.CurrentlyRecording)
                {
                    if (SettingService.PlayAudioFeedBackMarkingStartAndStopRecording)
                    {
                        audioPlaybackService.KillAudio(reset: true);

                        audioPlaybackService.QueueFile(audioPlaybackService.RecordStartAudioFeedbackPath);
                        audioPlaybackService.Play();

                        while (audioPlaybackService.PlaybackState != PlaybackState.Stopped)
                        {
                        }

                        audioPlaybackService.KillAudio(reset: true);
                    }

                    if (SettingService.ShowBalloonTipsForRecording)
                    {
                        _notificationManager.ShowAsync(
                            new NotificationContent()
                            {
                                Type    = NotificationType.Information,
                                Title   = "Recording started!",
                                Message = "RecNForget now recording..."
                            });
                    }

                    AudioPlaybackService.KillAudio(reset: true);
                    TaskBar_ProgressState = "Error";
                }
                else
                {
                    if (SettingService.PlayAudioFeedBackMarkingStartAndStopRecording || SettingService.AutoReplayAudioAfterRecording)
                    {
                        if (SettingService.PlayAudioFeedBackMarkingStartAndStopRecording)
                        {
                            actionService.QueueAudioPlayback(fileName: audioPlaybackService.RecordStopAudioFeedbackPath);
                        }

                        if (SettingService.AutoReplayAudioAfterRecording)
                        {
                            actionService.QueueAudioPlayback(
                                fileName: AudioRecordingService.LastFileName,
                                startIndicatorFileName: SettingService.PlayAudioFeedBackMarkingStartAndStopReplaying ? audioPlaybackService.ReplayStartAudioFeedbackPath : null,
                                endIndicatorFileName: SettingService.PlayAudioFeedBackMarkingStartAndStopReplaying ? audioPlaybackService.ReplayStopAudioFeedbackPath : null);
                        }

                        actionService.TogglePlayPauseAudio();
                    }

                    TaskBar_ProgressState = "None";

                    if (SettingService.ShowBalloonTipsForRecording)
                    {
                        _notificationManager.ShowAsync(
                            content: new NotificationContent()
                            {
                                Type    = NotificationType.Success,
                                Title   = "Recording saved!",
                                Message = AudioRecordingService.LastFileName
                            },
                            onClick: () =>
                            {
                                if (AudioRecordingService.LastFileName == string.Empty || !File.Exists(AudioRecordingService.LastFileName))
                                {
                                    return;
                                }

                                string argument = "/select, \"" + AudioRecordingService.LastFileName + "\"";
                                System.Diagnostics.Process.Start("explorer.exe", argument);
                            });
                    }

                    if (SettingService.AutoSelectLastRecording)
                    {
                        SelectedFileService.SelectFile(new FileInfo(AudioRecordingService.LastFileName));
                    }
                }

                break;
            }
            }
        }