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); } }
public void Launch(string url, string username) { if (Running) { Destroy(); isClosing = false; } lastUrl = url; lastUsername = username; try{ currentPipe = DuplexPipe.CreateServer(); currentPipe.DataIn += currentPipe_DataIn; if ((currentProcess = Process.Start(new ProcessStartInfo { FileName = Path.Combine(Program.ProgramPath, "TweetDuck.Video.exe"), Arguments = $"{owner.Handle} {Program.UserConfig.VideoPlayerVolume} \"{url}\" \"{currentPipe.GenerateToken()}\"", UseShellExecute = false, RedirectStandardOutput = true })) != null) { currentProcess.EnableRaisingEvents = true; currentProcess.Exited += process_Exited; #if DEBUG currentProcess.BeginOutputReadLine(); currentProcess.OutputDataReceived += (sender, args) => Debug.WriteLine("VideoPlayer: " + args.Data); #endif } currentPipe.DisposeToken(); }catch (Exception e) { Program.Reporter.HandleException("Video Playback Error", "Error launching video player.", true, e); } }