Exemple #1
0
 private void b_Detach_Click(object sender, EventArgs e)
 {
     if (isAttached)
     {
         MainForm.m.mainPlayer.Detach(myDetached, false);
     }
     else
     {
         Detached main = MainForm.m.mainPlayer;
         main.AttachPlayerToThis(myDetached, new Point((int)Math.Round(main.Width / 2f),
                                                       (int)Math.Round(main.Height / 2f)));
     }
 }
Exemple #2
0
        private static void Screenshot(Detached d, string path)
        {
            try {
                Panel player = d.p_Player;

                Image    bmp = new Bitmap(player.Width, player.Height);
                Graphics gfx = Graphics.FromImage(bmp);
                gfx.CopyFromScreen(player.RectangleToScreen(player.ClientRectangle).Location, Point.Empty, player.Size);

                bmp.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg);
            } catch (Exception e) {
                MessageBox.Show("SCREENSHOT\n" + e.ToString());
            }
        }
Exemple #3
0
        public void Detach(Detached detachable, bool destroy)
        {
            TabPage tp = detachable.settings.myLinkedPage;

            if (tp != null && settings.tC_PlayerSettings.TabPages.Contains(tp))
            {
                settings.tC_PlayerSettings.TabPages.Remove(tp);
            }

            detachable.RemoveSelfFromList();

            attachedPlayers.Remove(detachable);

            if (destroy)
            {
                detachable.DestroyPlayer();
                return;
            }

            detachable.settings.myLinkedPage = null;
            detachable.settings.isAttached   = false;

            bool wasPlaying = false;

            if (detachable.IsPlaying())
            {
                wasPlaying = true;
            }

            detachable.StopPlaying();
            detachable.settings.b_Detach.Text = "Attach";

            detachable.p_Player.Dispose();

            detachable.p_Player = (Panel)Tools.GetAllType(detachable, typeof(Panel)).First();
            detachable.Show();

            if (wasPlaying)
            {
                detachable.Play(false, false);
            }
        }
Exemple #4
0
        public SizeablePanel AttachPlayerToThis(Detached secondPlayer, Point pos, bool playOnLaunch = true)
        {
            try {
                secondPlayer.Hide();
                attachedPlayers.Add(secondPlayer);
                secondPlayer.settings.isAttached = true;

                SizeablePanel sP_Secondary = new SizeablePanel();
                secondPlayer.p_Player = sP_Secondary;
                p_Player.Controls.Add(sP_Secondary);

                sP_Secondary.Size     = new Size(300, 200);
                sP_Secondary.Location = pos;
                sP_Secondary.Anchor   = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);

                sP_Secondary.MouseDown += (s, e) => {
                    if (e.Button == MouseButtons.Right)
                    {
                        secondPlayer.settings.Show();
                        secondPlayer.settings.BringToFront();
                    }
                };

                sP_Secondary.DoubleClick += (s, e) => {
                    MainForm.m.SwapSettings(secondPlayer);
                };

                //string name = "Player " + (MainForm.m.mainPlayer.attachedPlayers.Count + 1).ToString();
                //secondPlayer.settings.tP_Main.Text = name;

                settings.AddPage(secondPlayer);
                secondPlayer.settings.b_Detach.Text = "Detach";

                secondPlayer.settings.LoadTabName();

                return(sP_Secondary);
            } catch (Exception e) {
                Tools.ShowPopup("Failed to attach player!\nShow more?", "Error Occurred!", e.ToString());
                return(null);
            }
        }
        void Record(string customPath)
        {
            try {
                string programPath = Application.ExecutablePath.Replace("SSUtility2.0.exe", "");
                string libPath     = programPath + "Lib/ffmpeg/ffmpeg.exe";
                if (!File.Exists(libPath))
                {
                    MessageBox.Show("Failed to find ffmpeg.exe!\nMissing File:\n" + libPath);
                    return;
                }

                string input   = "";
                string gdigrab = "-f gdigrab -draw_mouse 0 -video_size "
                                 + MainForm.m.mainPlayer.p_Player.Width + "x"
                                 + (MainForm.m.mainPlayer.p_Player.Height - MainForm.m.MenuBar.Height).ToString()
                                 + " -offset_y " + MainForm.m.MenuBar.Height;

                switch (type)
                {
                case RecordType.Player:
                    if (givenPlayer == null)
                    {
                        MessageBox.Show("No player given for player recording!");
                        return;
                    }
                    input   = givenPlayer.settings.GetCombined();
                    gdigrab = "";
                    break;

                case RecordType.SSUtility:
                    input       = "title=\"" + "SSUtility2.0" + "\"";
                    givenPlayer = null;
                    break;
                }

                if (customPath != "")
                {
                    outPath = Tools.PathNoOverwrite(customPath);
                }
                else
                {
                    outPath = Tools.GivePath(Tools.PathType.Video, givenPlayer);
                }

                string arguments = gdigrab + " -i " + input
                                   + " -framerate " + ConfigControl.recFPS.stringVal + " -b:v " + (ConfigControl.recQual.intVal * 30) + "k "
                                   + "\"" + outPath + "\"";

                Console.WriteLine("args-------------------" + arguments);
                p = new Process();
                p.StartInfo.UseShellExecute        = false;
                p.StartInfo.CreateNoWindow         = true;
                p.StartInfo.RedirectStandardInput  = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.FileName  = libPath;
                p.StartInfo.Arguments = arguments;

                p.Start();
                recording = true;
                MainForm.m.recorderProcessList.Add(p);
                return;
            } catch (Exception e) {
                Console.WriteLine("RECORD\n" + e.ToString());
                recording = false;
            }

            return;
        }
 public FFMPEGRecord(RecordType rt, Detached player, string customPath = "")
 {
     type        = rt;
     givenPlayer = player;
     Record(customPath);
 }
Exemple #7
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);
        }
Exemple #8
0
        public static string GivePath(PathType pt, Detached player, string customPath = "")
        {
            string defaultName, folder, name, full, folderType, extension;

            try {
                switch (pt)
                {
                case PathType.Snapshot:
                    defaultName = ConfigControl.scFileName.stringVal;
                    folder      = ConfigControl.scFolder.stringVal;
                    folderType  = "Snapshots";
                    extension   = ".jpg";
                    break;

                case PathType.Video:
                    defaultName = ConfigControl.vFileName.stringVal;
                    folder      = ConfigControl.vFolder.stringVal;
                    folderType  = "Recordings";
                    extension   = ".mp4";
                    break;

                case PathType.Panoramic:
                    defaultName = "Panoramic";
                    folder      = ConfigControl.scFolder.stringVal;
                    folderType  = "Panoramic";
                    extension   = ".jpg";
                    break;

                default:     //folder type
                    defaultName = "";
                    folder      = "";
                    folderType  = "";
                    extension   = "";
                    break;
                }

                if (ConfigControl.automaticPaths.boolVal && customPath == "")
                {
                    string playerName = "";

                    if (player != null)
                    {
                        playerName = player.settings.GetPresetName();
                    }
                    else
                    {
                        playerName = "SSUtility";
                    }

                    if (playerName != "" && playerName[playerName.Length - 1] != '\\')
                    {
                        playerName += @"\";
                    }
                    else if (playerName == "")
                    {
                        folderType = "";
                    }

                    folder = ConfigControl.savedFolder + playerName + folderType + @"\";

                    string timeText = "";
                    if (pt != PathType.Folder)
                    {
                        timeText = GetTimeText();
                    }

                    name = timeText;

                    if (defaultName != "")
                    {
                        name = defaultName + " " + timeText;
                    }

                    full = folder + name + timeText + extension;
                }
                else
                {
                    if (pt != PathType.Folder && folder[folder.Length - 1] != '\\')
                    {
                        folder += @"\";
                    }
                    else if (customPath != "")
                    {
                        folder = customPath;
                    }

                    full = folder + defaultName + extension;
                }

                if (pt != PathType.Folder)
                {
                    if (customPath == "")
                    {
                        CheckCreateFile(null, folder);
                    }

                    full = PathNoOverwrite(full);
                }

                Console.WriteLine(full);
            }catch (Exception e) {
                Console.WriteLine("GIVEPATH\n" + e.ToString());
                full = "";
            }

            full.Replace("//", "/");
            full.Replace("\\\\", "\\");

            return(full);
        }