Пример #1
0
        static void ThreadedRecordersAllStop()
        {
            try {
                foreach (Process pr in MainForm.m.recorderProcessList)
                {
                    StopRecording(pr, false);
                }

                foreach (Detached d in MainForm.m.detachedList)
                {
                    d.recorder = null;
                }

                ssutilRecorder = null;

                MainForm.m.recorderProcessList.Clear();
            } catch (Exception e) {
                MessageBox.Show("STOPALL\n" + e.ToString());
            }
        }
Пример #2
0
        public static async Task GlobalRecord()
        {
            string customTempFolder = ConfigControl.savedFolder + @"temp\";

            try {
                if (ssutilRecorder == null)
                {
                    StopAll();

                    List <string> listOfRecordingPresets = new List <string>();

                    Tools.CheckCreateFile(null, customTempFolder);

                    foreach (Detached d in MainForm.m.detachedList)
                    {
                        if (d.settings == null || !d.IsPlaying())
                        {
                            continue;
                        }

                        string presetName = d.settings.GetPresetName();

                        if (presetName == "" || listOfRecordingPresets.Contains(presetName))
                        {
                            continue;
                        }

                        d.recorder = null;
                        d.recorder = Tools.ToggleRecord(d, null, null, true, Tools.PathNoOverwrite(customTempFolder + presetName + ".mp4"));
                        if (d.recorder == null)
                        {
                            MessageBox.Show("Error occurred whilst trying to start global recorder!");
                            StopAll();
                            return;
                        }

                        listOfRecordingPresets.Add(presetName);
                    }

                    ssutilRecorder = Tools.ToggleRecord(null, MainForm.m.Menu_Recording_Video, MainForm.m.Menu_Recording_StopRecording, false, Tools.PathNoOverwrite(customTempFolder + "SSUtility.mp4"));
                    if (ssutilRecorder == null)
                    {
                        MessageBox.Show("Error occurred whilst trying to start global recorder!");
                        StopAll();
                        return;
                    }

                    prefixText = "Starting up... ";
                    InitIndicatorTimer();

                    await Task.Delay(5000);

                    MainForm.m.Menu_Recording_StopRecording.Enabled = true;
                    MainForm.m.Menu_RecordIndicator.Enabled         = true;
                    prefixText = "";
                }
                else
                {
                    indicatorTimer.Stop();
                    MainForm.m.Menu_RecordIndicator.Text = "Waiting for FFMPEG... ";
                    await Task.Delay(500);

                    List <string> outPaths = new List <string>();
                    foreach (Detached d in MainForm.m.detachedList)
                    {
                        if (d.recorder != null && d.recorder.recording)
                        {
                            outPaths.Add(d.recorder.outPath);
                        }
                    }

                    if (ssutilRecorder != null && ssutilRecorder.recording)
                    {
                        outPaths.Add(ssutilRecorder.outPath);
                    }

                    StopAll();
                    MainForm.m.Menu_Recording_StopRecording.Visible = false;

                    HideIndicator();
                    MainForm.m.Menu_RecordIndicator.Visible = false;

                    SaveFileDialog sfd = new SaveFileDialog();
                    sfd.FileName         = "-";
                    sfd.CheckFileExists  = false;
                    sfd.Filter           = "Directory | directory";
                    sfd.InitialDirectory = ConfigControl.savedFolder;
                    sfd.Title            = "Select a directory to save the recordings to";
                    DialogResult result = sfd.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        string fullPath = sfd.FileName;

                        if (Tools.CheckIfNameValid(fullPath) && !fullPath.EndsWith("-"))
                        {
                            if (!Directory.Exists(fullPath))
                            {
                                Directory.CreateDirectory(fullPath);
                            }
                        }
                        else
                        {
                            fullPath = fullPath.Substring(0, fullPath.LastIndexOf(@"\"));
                        }

                        if (fullPath.EndsWith(@"\"))
                        {
                            fullPath += @"\";
                        }

                        foreach (string path in outPaths)
                        {
                            Tools.CopySingleFile(fullPath + path.Substring(path.LastIndexOf(@"\")), path);
                        }

                        MessageBox.Show("Saved recordings to: " + fullPath);

                        MainForm.m.col.AddToSavedLocations(fullPath);

                        foreach (string path in outPaths)
                        {
                            File.Delete(path);
                        }

                        if (Directory.GetFiles(customTempFolder).Length == 0)
                        {
                            Directory.Delete(customTempFolder);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Saved recordings to: " + customTempFolder);
                    }

                    MainForm.m.Menu_Recording_Video.Visible         = true;
                    MainForm.m.Menu_Recording_StopRecording.Visible = false;
                    prefixText = "";
                }
            } catch (Exception e) {
                MessageBox.Show("GLOBALRECORDING\n" + e.ToString());
            }
        }
Пример #3
0
 private void Menu_Recording_StopRecording_Click(object sender, EventArgs e)
 {
     recorder = Tools.ToggleRecord(this, Menu_Recording_Video, Menu_Recording_StopRecording);
 }
Пример #4
0
 public void RemoveSelfFromList()
 {
     FFMPEGRecord.StopSingleInGlobal(this);
     MainForm.m.detachedList.Remove(this);
 }
Пример #5
0
        public static FFMPEGRecord ToggleRecord(Detached player, ToolStripMenuItem startRecord, ToolStripMenuItem stopRecord,
                                                bool showFinish = true, string customPath = "")
        {
            FFMPEGRecord.RecordType type = FFMPEGRecord.RecordType.SSUtility;

            FFMPEGRecord recorder;

            if (player != null)
            {
                type     = FFMPEGRecord.RecordType.Player;
                recorder = player.recorder;
            }
            else
            {
                recorder = FFMPEGRecord.ssutilRecorder;
            }

            if (recorder == null)
            {
                recorder = new FFMPEGRecord(type, player, customPath);

                if (!recorder.recording)
                {
                    recorder = null;
                }
                else if (startRecord != null)   //global gives null
                {
                    stopRecord.Text     = "Stop Recording";
                    stopRecord.Visible  = true;
                    startRecord.Visible = false;
                }
            }
            else
            {
                if (MainForm.m.finalMode)
                {
                    SaveFileDialog fdg    = Tools.SaveFile("Recording", ".mp4", MainForm.m.finalDest);
                    DialogResult   result = fdg.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        Tools.CopySingleFile(fdg.FileName, recorder.outPath);
                        MainForm.m.col.AddToSavedLocations(fdg.FileName);
                    }

                    MessageBox.Show("Saved recording to: " + recorder.outPath +
                                    "\nFinal saved: " + fdg.FileName);
                }
                else
                {
                    if (showFinish)
                    {
                        MessageBox.Show("Saved recording to: " + recorder.outPath);
                    }
                }

                FFMPEGRecord.StopRecording(recorder.p);
                recorder = null;

                if (startRecord != null)
                {
                    stopRecord.Visible  = false;
                    startRecord.Visible = true;
                }
            }

            return(recorder);
        }