public void Start_CapturesVideoUntilStopped() { var grabber = new ScreenGrabber(new CaptureParameters() { Zoom = 0.25 }); var video = new FlashScreenVideo(new FlashScreenVideoParameters(grabber.ScreenshotWidth, grabber.ScreenshotHeight, 5)); using (var recorder = new ScreenRecorder(grabber, video)) { recorder.Start(); Thread.Sleep(2000); recorder.Stop(); TestLog.EmbedVideo("Video", recorder.Video); } }
/// <summary> /// Starts recording a screen capture video of the entire desktop. /// </summary> /// <remarks> /// <para> /// Recording a screen capture video can be very CPU and space intensive particularly /// when running tests on a single-core CPU. We recommend calling /// <see cref="StartRecording(CaptureParameters, double)" /> with /// a <see cref="CaptureParameters.Zoom" /> factor of 0.25 or less and a frame rate /// of no more than 5 to 10 frames per second. /// </para> /// </remarks> /// <param name="parameters">The capture parameters.</param> /// <param name="framesPerSecond">The number of frames per second to capture.</param> /// <returns>The recorder.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="parameters"/> is null.</exception> /// <exception cref="ScreenshotNotAvailableException">Thrown if a screenshot cannot be captured at this time.</exception> public static ScreenRecorder StartRecording(CaptureParameters parameters, double framesPerSecond) { if (parameters == null) throw new ArgumentNullException("parameters"); ScreenGrabber.ThrowIfScreenshotNotAvailable(); ScreenGrabber grabber = new ScreenGrabber(parameters); try { FlashScreenVideo video = new FlashScreenVideo(new FlashScreenVideoParameters( grabber.ScreenshotWidth, grabber.ScreenshotHeight, framesPerSecond)); ScreenRecorder recorder = new ScreenRecorder(grabber, video); try { recorder.OverlayManager.AddOverlay(GetOverlayManager().ToOverlay()); recorder.Start(); return recorder; } catch { recorder.Dispose(); throw; } } catch { grabber.Dispose(); throw; } }
public void Start_WhenDisposed_Throws() { var grabber = new ScreenGrabber(new CaptureParameters()); var video = new FlashScreenVideo(new FlashScreenVideoParameters(grabber.ScreenshotWidth, grabber.ScreenshotHeight, 5)); var recorder = new ScreenRecorder(grabber, video); recorder.Dispose(); Assert.Throws<ObjectDisposedException>(() => recorder.Start()); }