Exemplo n.º 1
0
        private void currentPipe_DataIn(object sender, DuplexPipe.PipeReadEventArgs e)
        {
            owner.InvokeSafe(() => {
                switch (e.Key)
                {
                case "vol":
                    if (int.TryParse(e.Data, out int volume) && volume != Program.UserConfig.VideoPlayerVolume)
                    {
                        Program.UserConfig.VideoPlayerVolume = volume;
                        Program.UserConfig.Save();
                    }

                    break;

                case "download":
                    TwitterUtils.DownloadVideo(lastUrl, lastUsername);
                    break;

                case "rip":
                    currentPipe.Dispose();
                    currentPipe = null;

                    currentProcess.Dispose();
                    currentProcess = null;

                    isClosing = false;
                    TriggerProcessExitEventUnsafe();
                    break;
                }
            });
        }
Exemplo n.º 2
0
        public void Launch(string url, string username)
        {
            if (Running)
            {
                Destroy();
                isClosing = false;
            }

            try{
                DuplexPipe.Server pipe = DuplexPipe.CreateServer();
                pipe.DataIn += pipe_DataIn;

                Process process;

                if ((process = Process.Start(new ProcessStartInfo {
                    FileName = Path.Combine(Program.ProgramPath, "TweetDuck.Video.exe"),
                    Arguments = $"{owner.Handle} {(int)Math.Floor(100F * owner.GetDPIScale())} {Config.VideoPlayerVolume} \"{url}\" \"{pipe.GenerateToken()}\"",
                    UseShellExecute = false,
                    RedirectStandardOutput = true
                })) != null)
                {
                    currentInstance = new Instance(process, pipe, url, username);

                    process.EnableRaisingEvents = true;
                    process.Exited += process_Exited;

                    process.BeginOutputReadLine();
                    process.OutputDataReceived += process_OutputDataReceived;

                    pipe.DisposeToken();
                }
                else
                {
                    pipe.DataIn -= pipe_DataIn;
                    pipe.Dispose();
                }
            }catch (Exception e) {
                Program.Reporter.HandleException("Video Playback Error", "Error launching video player.", true, e);
            }
        }