public HotkeyAudioDevice GetDevice(string deviceName, AudioDeviceType deviceType = AudioDeviceType.Output) { if (deviceType == AudioDeviceType.Output) { return(AudioOutputDevices.FirstOrDefault(audioDevice => audioDevice.AudioDeviceName.Equals(deviceName))); } else if (deviceType == AudioDeviceType.Input) { return(AudioInputDevices.FirstOrDefault(audioDevice => audioDevice.AudioDeviceName.Equals(deviceName))); } else if (deviceType == AudioDeviceType.Both) { throw new Exception("Cannot use device type of both to get one device"); } return(null); }
public MainWindowViewModel(IVideoCaptureAccessor videoCaptureAccessor) { this.videoCaptureAccessor = videoCaptureAccessor; this.videoCaptureAccessor.OnError += VideoCaptureAccessorOnError; Title = "Simple Video Capture Demo - Video Capture SDK .Net" + " (SDK v" + videoCaptureAccessor.SDK_Version + ")"; SelectedVideoInputDevice = VideoInputDevices.FirstOrDefault(); SelectedAudioInputDevice = AudioInputDevices.FirstOrDefault(); SelectedAudioOutputDevice = AudioOutputDevices.FirstOrDefault(_ => _.Contains("Default DirectSound Device")) ?? AudioOutputDevices.FirstOrDefault(); RecordAudio = true; MinVolumeValue = 20; MaxVolumeValue = 100; CurrentVolumeValue = 80; MinBalanceValue = -100; MaxBalanceValue = 100; CurrentBalanceValue = 0; ConfigureAudioInputDeviceCommand = new DelegateCommand(ConfigureAudioInputDevice); ConfigureVideoInputDeviceCommand = new DelegateCommand(ConfigureVideoInputDevice); OutputFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "VisioForge", "output.mp4"); SelectedOutputFormat = OutputFormats.FirstOrDefault(_ => _.Description == "MP4") ?? OutputFormats.FirstOrDefault(); BrowseForOutputFileCommand = new DelegateCommand(BrowseForOutputFile); ConfigureOutputFormatCommand = new DelegateCommand(ConfigureOutputFormat); MinLightnessValue = 0; MaxLightnessValue = 255; CurrentLightnessValue = 0; MinSaturationValue = 0; MaxSaturationValue = 255; CurrentSaturationValue = 255; MinContrastValue = 0; MaxContrastValue = 255; CurrentContrastValue = 0; MinDarknessValue = 0; MaxDarknessValue = 255; CurrentContrastValue = 0; AddImageLogoCommand = new DelegateCommand(AddImageLogo); AddTextLogoCommand = new DelegateCommand(AddTextLogo); EditLogoCommand = new DelegateCommand(EditLogo, CanEditLogo); RemoveLogoCommand = new DelegateCommand(RemoveLogo, CanRemoveLogo); PreviewMode = true; RecordingTimeText = "Recording time: 00:00:00"; StartCommand = new DelegateCommand(Start); StopCommand = new DelegateCommand(Stop); PauseCommand = new DelegateCommand(Pause); ResumeCommand = new DelegateCommand(Resume); SaveSnapshotCommand = new DelegateCommand(SaveSnapshot); ViewVideoTutorialsCommand = new DelegateCommand(ViewVideoTutorials); tmRecording.Interval = TimeSpan.FromSeconds(1); tmRecording.Tick += (senderx, args) => { UpdateRecordingTime(); }; }