Advertisement
JasonHacks

Code

Apr 25th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using Microsoft.Expression.Encoder;
  12. using Microsoft.Expression.Encoder.Devices;
  13. using Microsoft.Expression.Encoder.ScreenCapture;
  14.  
  15. namespace Easy_record
  16. {
  17. public partial class Form1 : Form
  18. {
  19. private OutputFormat settings;
  20. private ScreenCaptureJob gotu;
  21.  
  22. public Form1()
  23. {
  24. InitializeComponent();
  25. }
  26.  
  27. private void Form1_Load(object sender, EventArgs e)
  28. {
  29.  
  30. }
  31.  
  32. private void Button1_Click(object sender, EventArgs e)
  33. {
  34. StartRecord();
  35. }
  36.  
  37. void StartRecord()
  38. {
  39. gotu = new ScreenCaptureJob();
  40. System.Drawing.Size size = SystemInformation.WorkingArea.Size;
  41. Rectangle car = new Rectangle(0, 0, size.Width - (size.Width % 4), size.Height - (size.Width % 4));
  42.  
  43.  
  44. gotu.CaptureRectangle = car;
  45. gotu.ShowCountdown = true;
  46. gotu.ShowFlashingBoundary = true;
  47. gotu.CaptureMouseCursor = true;
  48.  
  49. settings.VideoProfile.FrameRate = 60;
  50.  
  51. if(checkBox1.Checked == true)
  52. {
  53. gotu.AddAudioDeviceSource(Audiodevices());
  54. }
  55. gotu.OutputPath = @"D:\youtube recorder thingy";
  56. gotu.Start();
  57.  
  58. }
  59. EncoderDevice Audiodevices()
  60. {
  61. EncoderDevice foundDevice = null;
  62. Collection<EncoderDevice> audiodevices = EncoderDevices.FindDevices(EncoderDeviceType.Audio);
  63. try
  64. {
  65. foundDevice = audiodevices.First();
  66. }
  67. catch(Exception ex)
  68. {
  69. MessageBox.Show("Audio device not found", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
  70. }
  71. return foundDevice;
  72. }
  73.  
  74.  
  75. private void Button2_Click(object sender, EventArgs e)
  76. {
  77. if(gotu.Status == RecordStatus.Running)
  78. {
  79. gotu.Stop();
  80. }
  81. }
  82.  
  83. private void Form1_FormClosing(object sender, FormClosingEventArgs e)
  84. {
  85. if(gotu.Status == RecordStatus.Running)
  86. {
  87. MessageBox.Show("Unexpected quit. Throwing away recording NOW!", ":(", MessageBoxButtons.OK);
  88. gotu.Dispose();
  89. }
  90.  
  91. }
  92. }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement