Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using Microsoft.Expression.Encoder;
- using Microsoft.Expression.Encoder.Devices;
- using Microsoft.Expression.Encoder.ScreenCapture;
- namespace Easy_record
- {
- public partial class Form1 : Form
- {
- private OutputFormat settings;
- private ScreenCaptureJob gotu;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void Button1_Click(object sender, EventArgs e)
- {
- StartRecord();
- }
- void StartRecord()
- {
- gotu = new ScreenCaptureJob();
- System.Drawing.Size size = SystemInformation.WorkingArea.Size;
- Rectangle car = new Rectangle(0, 0, size.Width - (size.Width % 4), size.Height - (size.Width % 4));
- gotu.CaptureRectangle = car;
- gotu.ShowCountdown = true;
- gotu.ShowFlashingBoundary = true;
- gotu.CaptureMouseCursor = true;
- settings.VideoProfile.FrameRate = 60;
- if(checkBox1.Checked == true)
- {
- gotu.AddAudioDeviceSource(Audiodevices());
- }
- gotu.OutputPath = @"D:\youtube recorder thingy";
- gotu.Start();
- }
- EncoderDevice Audiodevices()
- {
- EncoderDevice foundDevice = null;
- Collection<EncoderDevice> audiodevices = EncoderDevices.FindDevices(EncoderDeviceType.Audio);
- try
- {
- foundDevice = audiodevices.First();
- }
- catch(Exception ex)
- {
- MessageBox.Show("Audio device not found", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- return foundDevice;
- }
- private void Button2_Click(object sender, EventArgs e)
- {
- if(gotu.Status == RecordStatus.Running)
- {
- gotu.Stop();
- }
- }
- private void Form1_FormClosing(object sender, FormClosingEventArgs e)
- {
- if(gotu.Status == RecordStatus.Running)
- {
- MessageBox.Show("Unexpected quit. Throwing away recording NOW!", ":(", MessageBoxButtons.OK);
- gotu.Dispose();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement