private async void buttonRec_Click(object sender, EventArgs e) { buttonRec.Enabled = false; await camLock.WaitAsync(); RecorderState status = cam.Recorder.Status; if (camLock.CurrentCount == 0) { camLock.Release(); } if (status == RecorderState.Stopped || status == RecorderState.PreRecording) { // start recording Command(() => cam.Recorder.Start(GetNextFileName()), true); buttonRec.Text = "STOP"; } else { // stop recording Command(() => cam.Recorder.Stop(), true); buttonRec.Text = "RECORD"; buttonPause.Text = "PAUSE"; } buttonRec.Enabled = true; }
public Recorder(Test test) { this.test = test; ScreenshotsEnabled = true; CurrentRecorderState = RecorderState.Stopped; globalHooker = new GlobalHooker(); globalHooker2 = new GlobalHooker(); keyboardHookListener = new KeyboardHookListener(globalHooker2); mouseHookListener = new MouseHookListener(globalHooker); keyboardHookListener.KeyDown += KeyboardHookListenerOnKeyDown; keyboardHookListener.KeyUp += KeyboardHookListenerOnKeyUp; mouseHookListener.MouseDown += MouseHookListenerOnMouseDown; mouseHookListener.MouseUp += MouseHookListenerOnMouseUp; mouseHookListener.Enabled = false; mouseHookListener.Enabled = false; keyboardHelper = new KeyboardHelper(); currentInputType = InputType.None; InsertPosition = -1; }
public XnaRecorder(Stream stream, EncodingFormat format, int preset) { if (stream == null) { throw new ArgumentNullException("stream"); } _stream = stream; _sampleRate = 16000; _bitRate = 16; _channels = 1; _format = format; _preset = preset; _size = 0; _duration = 0; _state = RecorderState.Unknown; InitializeMicrophone(); if (_format == EncodingFormat.Wave) { _writer = new WaveWriter(_stream, _sampleRate, _bitRate, _channels); } else if (_format == EncodingFormat.MP3) { _writer = new Mp3Writer(_stream, _sampleRate, _bitRate, _channels, (LAMEPreset)_preset); } }
public void Stop() { Recorder.isRecording = false; PupilGazeTracker.Instance.StopPupilServiceRecording(); _recorderState = RecorderState.PROCESSING; Recorder.isProcessing = true; }
/// <summary> /// Pre-processing coroutine to extract frame data and send everything to a separate worker thread /// <summary> private IEnumerator OnGenerate() { // Switch the state to pause, let the user choose to keep recording or not State = RecorderState.Paused; // Setup a worker thread and let it do its magic GifEncoder encoder = new GifEncoder(m_Repeat, m_Quality); encoder.SetDelay(Mathf.RoundToInt(m_TimePerFrame * 1000f)); var worker = new Worker(WorkerPriority) { m_Encoder = encoder, m_Frames = captureList, m_OnProgressHandler = OnProgressHandler }; worker.Start(); yield return(new WaitUntil(() => { return worker.IsComplete; })); var result = (worker.GifImage != null) ? worker.GifImage : new byte[] {}; Debug.Log("on record complete."); //yield return OnCompletedHandler(result); onCompletedHandler?.Invoke(result); }
/// <summary> /// Used to reset internal values, called on Start(), Setup() and FlushMemory() /// </summary> private void InitializeParameter() { State = RecorderState.Paused; m_MaxFrameCount = Mathf.RoundToInt(m_BufferSize * m_FramePerSecond); m_TimePerFrame = 1f / m_FramePerSecond; m_Time = 0f; }
private void stop() { progressTimer.Stop(); if (microphone.State == MicrophoneState.Started) { // In RECORD mode, user clicked the // stop button to end recording microphone.Stop(); UpdateWavHeader(stream); } else if (soundInstance != null && soundInstance.State == SoundState.Playing) { soundInstance.Stop(); } timeBar.Opacity = 0; if (myState == RecorderState.RECORDING) { recordedDuration = runningSeconds; runningTime.Text = formatTime(0); } runningSeconds = 0; message.Text = AppResources.RecordAudio_Play; statusImage.Source = playIcon; sendIconButton.IsEnabled = true; myState = RecorderState.RECORDED; }
void cam_RecorderStatusChanged(object sender, Flir.Atlas.Live.Recorder.RecorderStatusChangedEventArgs e) { RecorderState status = e.State; Boolean indicator = false; string recState = ""; if (status == RecorderState.Stopped) { recState = "Stop"; indicator = false; } else if (status == RecorderState.Recording) { recState = "Recording"; indicator = true; } else if (status == RecorderState.Paused) { recState = "Paused"; indicator = false; } BeginInvoke((Action)(() => { recordStatus.Text = recState; recordIndicator.Visible = indicator; })); }
private void ChangeState(RecorderState nextState) { switch (nextState) { case RecorderState.Inactive: { togglePlayback.SetEnabled(false); framesParent.SetEnabled(false); playbackParent.SetEnabled(false); toggleRecording.text = "Enable Frame Recorder"; break; } case RecorderState.Recording: { toggleRecording.text = "Disable Frame Recorder"; togglePlayback.text = "Start Playback"; if (playbackPauseGame.value && EditorApplication.isPaused) { EditorApplication.isPaused = false; } FrameRecorderEditorProxy.PlaybackRange = vec2i(0); frameCapacity.value = FrameRecorderEditorProxy.FrameCapacity; togglePlayback.SetEnabled(true); framesParent.SetEnabled(false); playbackParent.SetEnabled(false); break; } case RecorderState.Playback: { togglePlayback.text = "Stop Playback"; if (playbackPauseGame.value && !EditorApplication.isPaused) { EditorApplication.isPaused = true; } frameCapacity.value = FrameRecorderEditorProxy.FrameCapacity; togglePlayback.SetEnabled(true); framesParent.SetEnabled(true); playbackParent.SetEnabled(true); break; } } if (EditorApplication.isPlaying) { playbackSingle.value = FrameRecorderEditorProxy.PlaybackRange.x; playbackMultiple.value = FrameRecorderEditorProxy.PlaybackRange; lastState = nextState; } }
public void Replay() { player.position = spawnPoint.position; recorderState = RecorderState.replaying; StartCoroutine(PlayRecordingSteps()); }
private void BeginRecording() { frame = 0; state = RecorderState.Recording; MemoryStream baseStream = new MemoryStream(); stream = new RecordingStream(1, write: true, baseStream); }
public void Record() { recorderState = RecorderState.recording; sessionLog = new SessionLog(DateTime.Now.ToString("dd-MM-yy-HH-mm-ss"), "TestMap"); InvokeRepeating("Logger", 0, loggerTick); }
/** * Sets a new state. When recording stops the data gets saved * */ public void SetState(RecorderState state) { if (this.state == RecorderState.RECORD) { this.save(); } this.state = state; this.ReloadState(); }
public Recorder(int numReads, int numFramesRead, bool auto) { numOfReads = numReads; numOfFramesPerRead = numFramesRead; isAuto = auto; sequencesToRead = new List<List<Frame>>(); state = RecorderState.Starting; actualNumOfReads = 0; }
public void Resume() { if (_state == RecorderState.Stopped || _state == RecorderState.Unknown) { throw new InvalidOperationException("No recording in progress."); } _state = RecorderState.Recording; }
private void onRecordButtonClick(object sender, RoutedEventArgs e) { if (state == RecorderState.Idle) { recordButton.Content = strRecording; state = RecorderState.Recording; } else if (state == RecorderState.Recording) { recordButton.Content = strStartRecording; state = RecorderState.Idle; } OnRecordStateChanged(); }
public void Read(string path) { RecordListener listener = new RecordListener(); listener.Initialization(numOfFramesPerRead, this); Controller controller = new Controller(); controller.AddListener(listener); actualNumOfReads = 0; Console.WriteLine("Press enter to start reading frames to file " + path); Console.ReadLine(); state = RecorderState.Idle; while (state != RecorderState.Saving) { Console.WriteLine("num: " + (actualNumOfReads + 1) + " in " + numOfReads); if (!isAuto) { Console.ReadLine(); } state = RecorderState.Reading; Console.WriteLine("Reading..."); while (state == RecorderState.Reading) { if (numOfFramesPerRead == 0) { Console.ReadLine(); listener.GetSequence(); } } while (state == RecorderState.Storing) { } } while (state != RecorderState.Saving) { } Utils.SaveListListFrame(sequencesToRead, path); controller.RemoveListener(listener); controller.Dispose(); }
/// <summary> /// Saves the stored frames to a gif file. If the filename is null or empty, an unique one /// will be generated. You don't need to add the .gif extension to the name. Recording will /// be paused and won't resume automatically. You can use the <code>OnPreProcessingDone</code> /// callback to be notified when the pre-processing step has finished. /// </summary> /// <param name="filename">File name without extension</param> public void Save(string filename) { if (State == RecorderState.PreProcessing) { Debug.LogWarning("Attempting to save during the pre-processing step."); return; } if (m_Frames.Count == 0) { Debug.LogWarning("Nothing to save. Maybe you forgot to start the recorder ?"); return; } State = RecorderState.PreProcessing; if (string.IsNullOrEmpty(filename)) filename = GenerateFileName(); StartCoroutine(PreProcess(filename)); }
/// <summary> /// Starts or resumes recording. You can't resume while it's pre-processing data to be saved. /// </summary> public void Record() { if (State == RecorderState.PreProcessing) { Debug.LogWarning("Attempting to resume recording during the pre-processing step."); return; } State = RecorderState.Recording; }
/// <summary> /// Pauses recording. /// </summary> public void Pause() { if (State == RecorderState.PreProcessing) { Debug.LogWarning("Attempting to pause recording during the pre-processing step. The recorder is automatically paused when pre-processing."); return; } State = RecorderState.Paused; }
private void Initialize() { recordButton.Content = strStartRecording; state = RecorderState.Idle; }
/// <summary> /// Initiates a playback session. /// </summary> public static void BeginPlayBack(string recordingName) { if (recorder == null) throw new InvalidOperationException("A recorder needs to be registered to the recorder before starting a RecorderManager session."); if (action != RecorderState.None) throw new InvalidOperationException("Recorder is already busy playing or recording."); currentRecordingName = recordingName; MockService.ResetSession(); recorder.BeginPlayBack(recordingName); action = RecorderState.PlayBack; if (OnBeginPlayback != null) OnBeginPlayback(recorder, EventArgs.Empty); }
/// <summary> /// Ends the current playback session. /// </summary> public static void EndPlayBack() { if (action != RecorderState.PlayBack) throw new InvalidOperationException("Recorder is not currently playing."); if (OnEndPlayback != null) OnEndPlayback(recorder, EventArgs.Empty); recorder.EndPlayBack(); MockService.ResetSession(); currentRecordingName = null; action = RecorderState.None; }
/** Sets the play state to playing. */ public void Play() { state = RecorderState.Playing; }
/** Sets the play state to stopped. Also resets the frame index to 0. */ public void Stop() { state = RecorderState.Stopped; frame_index_ = 0.0f; }
public void Pause() { state = RecorderState.Idling; }
// Used to reset internal values, called on Start(), Setup() and FlushMemory() void Init() { State = RecorderState.Paused; ComputeHeight(); m_MaxFrameCount = Mathf.RoundToInt(m_BufferSize * m_FramePerSecond); m_TimePerFrame = 1f / m_FramePerSecond; m_Time = 0f; // Make sure the output folder is set or use the default one if (string.IsNullOrEmpty(SaveFolder)) { #if UNITY_EDITOR SaveFolder = Application.dataPath; // Defaults to the asset folder in the editor for faster access to the gif file #else SaveFolder = Application.persistentDataPath; #endif } }
// Pre-processing coroutine to extract frame data and send everything to a separate worker thread IEnumerator PreProcess(string filename) { string filepath = SaveFolder + "/" + filename + ".gif"; List<GifFrame> frames = new List<GifFrame>(m_Frames.Count); // Get a temporary texture to read RenderTexture data Texture2D temp = new Texture2D(m_Width, m_Height, TextureFormat.RGB24, false); temp.hideFlags = HideFlags.HideAndDontSave; temp.wrapMode = TextureWrapMode.Clamp; temp.filterMode = FilterMode.Bilinear; temp.anisoLevel = 0; // Process the frame queue while (m_Frames.Count > 0) { GifFrame frame = ToGifFrame(m_Frames.Dequeue(), temp); frames.Add(frame); yield return null; } // Dispose the temporary texture Flush(temp); // Switch the state to pause, let the user choose to keep recording or not State = RecorderState.Paused; // Callback if (OnPreProcessingDone != null) OnPreProcessingDone(); // Setup a worker thread and let it do its magic GifEncoder encoder = new GifEncoder(m_Repeat, m_Quality); encoder.SetDelay(Mathf.RoundToInt(m_TimePerFrame * 1000f)); Worker worker = new Worker(WorkerPriority) { m_Encoder = encoder, m_Frames = frames, m_FilePath = filepath, m_OnFileSaved = OnFileSaved, m_OnFileSaveProgress = OnFileSaveProgress }; worker.Start(); }
public void Pause() { CurrentRecorderState = RecorderState.Paused; mouseHookListener.Enabled = false; keyboardHookListener.Enabled = false; }
public void Stop() { state = RecorderState.Idling; frame_index_ = 0.0f; }
public void Record() { CurrentRecorderState = RecorderState.Recording; mouseHookListener.Enabled = true; keyboardHookListener.Enabled = true; }
/** Sets the play state to paused. */ public void Pause() { state = RecorderState.Paused; }
public void Stop() { if (CurrentRecorderState == RecorderState.Stopped) { return; } CurrentRecorderState = RecorderState.Stopped; mouseHookListener.Enabled = false; keyboardHookListener.Enabled = false; while (executingTasks.Count > 0) { try { Task task = executingTasks.FirstOrDefault(); if (task == null) continue; if (task.IsCompleted) executingTasks.Remove(task); task.Wait(); } catch (Exception e) { } } if (InsertPosition < 0) { test.TestItems.AddRange(newTestItems); return; } for (int i = 0; i < newTestItems.Count; i++) { test.TestItems.Insert(InsertPosition + i, newTestItems[0]); } }
/** Sets the play state to recording. */ public void Record() { state = RecorderState.Recording; }
public void Store(List<Frame> handSeq) { actualNumOfReads++; sequencesToRead.Add(handSeq); if (actualNumOfReads >= numOfReads) { state = RecorderState.Saving; } else { state = RecorderState.Idle; } }