public bool StartRecording() { VideoStreamerRecordingPreset preset = VideoStreamerRecordingPreset.Source; if (String.IsNullOrWhiteSpace(_recordingConfig.Preset) == false) { preset = VideoStreamerRecordingPreset.Presets.FirstOrDefault(p => p.Name == _recordingConfig.Preset) ?? preset; } string codecArgs = _config.FFmpegCodecArgs .Replace("{resolutionScale}", preset.ResolutionScale) .Replace("{bitrate}", preset.Bitrate.ToString()) .Replace("{framerate}", preset.FrameRate.ToString()); string targetPath = Path.ChangeExtension(_recordingConfig.TargetPath, _config.Extension); bool started = _streamer.StartRecordingProcess(FFmpegStreamType.VIDEO, _selectedDevice, targetPath, codecArgs); if (started) { RecordingStarted?.Invoke(this, EventArgs.Empty); } return(started); }
protected virtual void OnRecordingStart() { if (RecordingStarted != null) { RecordingStarted.Invoke(this, EventArgs.Empty); } }
private void SafeInvokeRecordingStarted(CaptureConfig config) { if (RecordingStarted == null) { return; //No Listeners } RecordingStartedEvent listener = null; Delegate[] dels = RecordingStarted.GetInvocationList(); foreach (Delegate del in dels) { try { listener = (RecordingStartedEvent)del; listener.Invoke(config); } catch (Exception) { //Could not reach the destination, so remove it //from the list RecordingStarted -= listener; } } }
public void StartRecording() { StopPlay(); _audioBuffer.Clear(); _audioBufferPlaybackPosition = 0; var fileName = Path.Combine(_dir, Directory.GetFiles(_dir).Length.ToString().PadLeft(4, '0') + ".wav"); _waveWriter = new WaveFileWriter(fileName, _waveIn.WaveFormat); Recording = true; RecordingStarted?.Invoke(); }
public void Start() { try { WaveIn.StartRecording(); timer.Start(); RecordingStarted?.Invoke(this, new EventArgs()); Console.WriteLine("Audio recording started"); } catch { string msg = "Could not record from audio device!\n\n"; msg += "Is your microphone plugged in?\n"; msg += "Is it set as your default recording device?"; MessageBox.Show(msg, "ERROR"); } }
public async void Start(InstaDirectInboxThread thread) { CurrentThread = thread; await _recordQueue.Enqueue(async() => { if (_recorder != null) { RecordingFailed?.Invoke(this, EventArgs.Empty); return; } var fileName = string.Format("voice_{0:yyyy}-{0:MM}-{0:dd}_{0:HH}-{0:mm}-{0:ss}.mp3", DateTime.Now); var cache = await localFolder.CreateFileAsync(fileName, CreationCollisionOption.GenerateUniqueName); try { _file = cache; _recorder = new Mp3Recorder(cache) { m_mediaCapture = new MediaCapture() }; await _recorder.m_mediaCapture.InitializeAsync(/*_recorder.settings*/); await _recorder.StartAsync(); _start = DateTime.Now; } catch (Exception ex) { _recorder.Dispose(); _recorder = null; _file = null; RecordingFailed?.Invoke(this, EventArgs.Empty); return; } RecordingStarted?.Invoke(this, EventArgs.Empty); }); }
public bool StartRecording() { if (String.IsNullOrWhiteSpace(_selectedDevice) == false && _streamer.IsRunning == false) { Log?.Invoke(this, new Core.LogMessage(Core.LogLevel.Info, LogTags.Recording, "Starting recording...")); string codecArgs = _config.FFmpegCodecArgs .Replace("{bitrate}", _recordingConfig.Bitrate.ToString()); string targetPath = Path.ChangeExtension(_recordingConfig.TargetPath, _config.Extension); bool started = _streamer.StartRecordingProcess(FFmpegStreamType.AUDIO, _selectedDevice, targetPath, codecArgs); if (started) { RecordingStarted?.Invoke(this, EventArgs.Empty); Log?.Invoke(this, new Core.LogMessage(Core.LogLevel.Info, LogTags.Recording, "Recording started")); } return(started); } return(false); }
protected void OnRecordingStarted() { RecordingStarted?.Invoke(); }
private static void RemoveAllEventHandlers() { if (RecordingStarted != null) { foreach (LuYou.RecordingStartedDelegate del in RecordingStarted.GetInvocationList()) { RecordingStarted -= del; } } if (RecordingStoped != null) { foreach (LuYou.RecordingStopedDelegate del in RecordingStoped.GetInvocationList()) { RecordingStoped -= del; } } if (RecordingFailed != null) { foreach (LuYou.RecordingFailedDelegate del in RecordingFailed.GetInvocationList()) { RecordingFailed -= del; } } if (RecordingWarning != null) { foreach (LuYou.RecordingWarningDelegate del in RecordingWarning.GetInvocationList()) { RecordingWarning -= del; } } if (RecordingTime != null) { foreach (LuYou.RecordingTimeDelegate del in RecordingTime.GetInvocationList()) { RecordingTime -= del; } } if (RecordingStarted != null) { foreach (LuYou.RecordingStartedDelegate del in RecordingStarted.GetInvocationList()) { RecordingStarted -= del; } } if (SharerPreing != null) { foreach (LuYou.SharerPreingDelegate del in SharerPreing.GetInvocationList()) { SharerPreing -= del; } } if (SharerPrepared != null) { foreach (LuYou.SharerPreparedDelegate del in SharerPrepared.GetInvocationList()) { SharerPrepared -= del; } } if (SharerFailed != null) { foreach (LuYou.SharerFailedDelegate del in SharerFailed.GetInvocationList()) { SharerFailed -= del; } } if (SharerProgress != null) { foreach (LuYou.SharerProgressDelegate del in SharerProgress.GetInvocationList()) { SharerProgress -= del; } } if (SharerComplete != null) { foreach (LuYou.SharerCompleteDelegate del in SharerComplete.GetInvocationList()) { SharerComplete -= del; } } if (SharerStarted != null) { foreach (LuYou.SharerStartedDelegate del in SharerStarted.GetInvocationList()) { SharerStarted -= del; } } }
private void StartNewRecording() { startNewRecording = false; Reset(); RecordingStarted?.Invoke(this, ActionRecorderEventArgs.Empty); }
/// <summary> /// Raises the <see cref="RecordingStarted" /> event. /// </summary> /// <seealso cref="EventArgs" /> protected virtual void OnRecordingStarted() { RecordingStarted?.Invoke(this, EventArgs.Empty); }
private void AriClient_OnRecordingStartedEvent(IAriClient sender, RecordingStartedEvent e) { RecordingStarted?.Invoke(this, e); }
private void Start() { _video = IsVideo; Task.Run(async() => { _startReset.WaitOne(); _startReset.Reset(); _recording = true; _start = DateTime.Now; this.BeginOnUIThread(() => { if (_video) { _roundView.IsOpen = true; } RecordingStarted?.Invoke(this, EventArgs.Empty); }); //_stopReset.Set(); //return; _file = await ApplicationData.Current.LocalFolder.CreateFileAsync(_video ? "temp\\recording.mp4" : "temp\\recording.ogg", CreationCollisionOption.ReplaceExisting); _recorder = new OpusRecorder(_file, _video); /* This following was moved from sub thread, because of a exception which comes from that device initializiation * is only allowed from UI thread! */ if (_recorder.m_mediaCapture != null) { Debug.WriteLine("Cannot start while recording"); } try { _recorder.m_mediaCapture = new MediaCapture(); var cameraDevice = await _recorder.FindCameraDeviceByPanelAsync(Windows.Devices.Enumeration.Panel.Front); if (cameraDevice == null) { // TODO: ... } // Figure out where the camera is located if (cameraDevice.EnclosureLocation == null || cameraDevice.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Unknown) { // No information on the location of the camera, assume it's an external camera, not integrated on the device _recorder._externalCamera = true; } else { // Camera is fixed on the device _recorder._externalCamera = false; // Only mirror the preview if the camera is on the front panel _recorder._mirroringPreview = (cameraDevice.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front); } _recorder.settings.VideoDeviceId = cameraDevice.Id; await _recorder.m_mediaCapture.InitializeAsync(_recorder.settings); await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { if (_video) { // Initialize rotationHelper _recorder._rotationHelper = new CameraRotationHelper(cameraDevice.EnclosureLocation); _recorder._rotationHelper.OrientationChanged += RotationHelper_OrientationChanged; await _roundView.SetAsync(_recorder.m_mediaCapture, _recorder._mirroringPreview); await _recorder.SetPreviewRotationAsync(); } }); await _recorder.StartAsync(); } catch (UnauthorizedAccessException) { Debug.WriteLine("The access to microphone was denied!"); return; } catch (Exception) { Debug.WriteLine("The app couldn't initialize microphone!"); return; } _pressed = true; _cancelOnRelease = false; _start = DateTime.Now; _stopReset.Set(); Debug.WriteLine("Start: " + _start); Debug.WriteLine("Stop unlocked"); }); }
// Private static methods private static void RemoveAllEventHandlers() { if (WasClosed != null) { foreach (Everyplay.WasClosedDelegate del in WasClosed.GetInvocationList()) { WasClosed -= del; } } if (ReadyForRecording != null) { foreach (Everyplay.ReadyForRecordingDelegate del in ReadyForRecording.GetInvocationList()) { ReadyForRecording -= del; } } if (RecordingStarted != null) { foreach (Everyplay.RecordingStartedDelegate del in RecordingStarted.GetInvocationList()) { RecordingStarted -= del; } } if (RecordingStopped != null) { foreach (Everyplay.RecordingStoppedDelegate del in RecordingStopped.GetInvocationList()) { RecordingStopped -= del; } } if (FaceCamSessionStarted != null) { foreach (Everyplay.FaceCamSessionStartedDelegate del in FaceCamSessionStarted.GetInvocationList()) { FaceCamSessionStarted -= del; } } if (FaceCamRecordingPermission != null) { foreach (Everyplay.FaceCamRecordingPermissionDelegate del in FaceCamRecordingPermission.GetInvocationList()) { FaceCamRecordingPermission -= del; } } if (FaceCamSessionStopped != null) { foreach (Everyplay.FaceCamSessionStoppedDelegate del in FaceCamSessionStopped.GetInvocationList()) { FaceCamSessionStopped -= del; } } if (ThumbnailReadyAtFilePath != null) { foreach (Everyplay.ThumbnailReadyAtFilePathDelegate del in ThumbnailReadyAtFilePath.GetInvocationList()) { ThumbnailReadyAtFilePath -= del; } } if (ThumbnailReadyAtTextureId != null) { foreach (Everyplay.ThumbnailReadyAtTextureIdDelegate del in ThumbnailReadyAtTextureId.GetInvocationList()) { ThumbnailReadyAtTextureId -= del; } } if (UploadDidStart != null) { foreach (Everyplay.UploadDidStartDelegate del in UploadDidStart.GetInvocationList()) { UploadDidStart -= del; } } if (UploadDidProgress != null) { foreach (Everyplay.UploadDidProgressDelegate del in UploadDidProgress.GetInvocationList()) { UploadDidProgress -= del; } } if (UploadDidComplete != null) { foreach (Everyplay.UploadDidCompleteDelegate del in UploadDidComplete.GetInvocationList()) { UploadDidComplete -= del; } } }
private void UpdateRecordingInterface() { Logger.Debug(Target.Recording, "Updating interface, state: " + recordInterfaceState); if (_recordingLocked && _recordingAudioVideo) { if (recordInterfaceState == 2) { return; } recordInterfaceState = 2; this.BeginOnUIThread(() => { VisualStateManager.GoToState(this, "Locked", false); ClickMode = ClickMode.Press; RecordingLocked?.Invoke(this, EventArgs.Empty); }); } else if (_recordingAudioVideo) { if (recordInterfaceState == 1) { return; } recordInterfaceState = 1; try { if (_request == null) { _request = new DisplayRequest(); _request.GetType(); } } catch { } _recordingLocked = false; _start = DateTime.Now; this.BeginOnUIThread(() => { VisualStateManager.GoToState(this, "Started", false); ClickMode = ClickMode.Release; RecordingStarted?.Invoke(this, EventArgs.Empty); }); } else { if (_request != null) { try { _request.RequestRelease(); _request = null; } catch { } } if (recordInterfaceState == 0) { return; } recordInterfaceState = 0; _recordingLocked = false; this.BeginOnUIThread(() => { VisualStateManager.GoToState(this, "Stopped", false); ClickMode = ClickMode.Press; RecordingStopped?.Invoke(this, EventArgs.Empty); }); } Logger.Debug(Target.Recording, "Updated interface, state: " + recordInterfaceState); }
private void Start() { _video = IsVideo; Task.Run(async() => { _startReset.WaitOne(); _startReset.Reset(); _recording = true; _start = DateTime.Now; Execute.BeginOnUIThread(() => { if (_video) { _roundView.IsOpen = true; } RecordingStarted?.Invoke(this, EventArgs.Empty); }); //_stopReset.Set(); //return; _file = await ApplicationData.Current.LocalFolder.CreateFileAsync(_video ? "temp\\recording.mp4" : "temp\\recording.ogg", CreationCollisionOption.ReplaceExisting); _recorder = new OpusRecorder(_file, _video); /* This following was moved from sub thread, because of a exception which comes from that device initializiation * is only allowed from UI thread! */ if (_recorder.m_mediaCapture != null) { Debug.WriteLine("Cannot start while recording"); } try { _recorder.m_mediaCapture = new MediaCapture(); var cameraDevice = await _recorder.FindCameraDeviceByPanelAsync(Windows.Devices.Enumeration.Panel.Front); _recorder.settings.VideoDeviceId = cameraDevice.Id; await _recorder.m_mediaCapture.InitializeAsync(_recorder.settings); if (_video) { await _roundView.SetAsync(_recorder.m_mediaCapture); } await _recorder.StartAsync(); } catch (UnauthorizedAccessException) { Debug.WriteLine("The access to microphone was denied!"); return; } catch (Exception) { Debug.WriteLine("The app couldn't initialize microphone!"); return; } _pressed = true; _cancelOnRelease = false; _start = DateTime.Now; _stopReset.Set(); Debug.WriteLine("Start: " + _start); Debug.WriteLine("Stop unlocked"); }); }
public async void Start(ChatRecordMode mode) { Logger.Debug(Target.Recording, "Start invoked, mode: " + mode); await _recordQueue.Enqueue(async() => { Logger.Debug(Target.Recording, "Enqueued start invoked"); if (_recorder != null) { Logger.Debug(Target.Recording, "_recorder != null, abort"); RecordingFailed?.Invoke(this, EventArgs.Empty); return; } // Create a new temporary file for the recording var fileName = string.Format(mode == ChatRecordMode.Video ? "video_{0:yyyy}-{0:MM}-{0:dd}_{0:HH}-{0:mm}-{0:ss}.mp4" : "voice_{0:yyyy}-{0:MM}-{0:dd}_{0:HH}-{0:mm}-{0:ss}.ogg", DateTime.Now); var cache = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(fileName, CreationCollisionOption.GenerateUniqueName); try { _mode = mode; _file = cache; _recorder = new OpusRecorder(cache, mode == ChatRecordMode.Video); _recorder.m_mediaCapture = new MediaCapture(); if (mode == ChatRecordMode.Video) { var cameraDevice = await _recorder.FindCameraDeviceByPanelAsync(Windows.Devices.Enumeration.Panel.Front); if (cameraDevice == null) { // TODO: ... } // Figure out where the camera is located if (cameraDevice.EnclosureLocation == null || cameraDevice.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Unknown) { // No information on the location of the camera, assume it's an external camera, not integrated on the device _recorder._externalCamera = true; } else { // Camera is fixed on the device _recorder._externalCamera = false; // Only mirror the preview if the camera is on the front panel _recorder._mirroringPreview = cameraDevice.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front; } _recorder.settings.VideoDeviceId = cameraDevice.Id; } await _recorder.m_mediaCapture.InitializeAsync(_recorder.settings); Logger.Debug(Target.Recording, "Devices initialized, starting"); await _recorder.StartAsync(); Logger.Debug(Target.Recording, "Recording started at " + DateTime.Now); _start = DateTime.Now; } catch (Exception ex) { Logger.Debug(Target.Recording, "Failed to initialize devices, abort: " + ex); _recorder.Dispose(); _recorder = null; _file = null; RecordingFailed?.Invoke(this, EventArgs.Empty); return; } RecordingStarted?.Invoke(this, EventArgs.Empty); }); }
public void RecordingStartedProxyHandler(CaptureConfig config) { RecordingStarted?.Invoke(config); }