diff --git a/Core/Other/Management/VideoPlayer.cs b/Core/Other/Management/VideoPlayer.cs index ed3682b6..e8bd096a 100644 --- a/Core/Other/Management/VideoPlayer.cs +++ b/Core/Other/Management/VideoPlayer.cs @@ -55,11 +55,9 @@ public void Launch(string url, string username){ })) != null){ currentProcess.EnableRaisingEvents = true; currentProcess.Exited += process_Exited; - - #if DEBUG + currentProcess.BeginOutputReadLine(); - currentProcess.OutputDataReceived += (sender, args) => Debug.WriteLine("VideoPlayer: "+args.Data); - #endif + currentProcess.OutputDataReceived += process_OutputDataReceived; } currentPipe.DisposeToken(); @@ -146,6 +144,12 @@ private void owner_FormClosing(object sender, FormClosingEventArgs e){ } } + private void process_OutputDataReceived(object sender, DataReceivedEventArgs e){ + if (!string.IsNullOrEmpty(e.Data)){ + Program.Reporter.Log("[VideoPlayer] "+e.Data); + } + } + private void process_Exited(object sender, EventArgs e){ int exitCode = currentProcess.ExitCode; diff --git a/Reporter.cs b/Reporter.cs index eb7ac857..ccd0a9f0 100644 --- a/Reporter.cs +++ b/Reporter.cs @@ -23,6 +23,10 @@ public void SetupUnhandledExceptionHandler(string caption){ } public bool Log(string data){ + #if DEBUG + Debug.WriteLine(data); + #endif + StringBuilder build = new StringBuilder(); if (!File.Exists(logFile)){ diff --git a/video/FormPlayer.cs b/video/FormPlayer.cs index 37f3ba0f..05121e06 100644 --- a/video/FormPlayer.cs +++ b/video/FormPlayer.cs @@ -102,8 +102,10 @@ private void player_PlayStateChange(int newState){ } private void player_MediaError(object pMediaObject){ - Console.Out.WriteLine(((IWMPMedia2)pMediaObject).Error.errorDescription); + IWMPErrorItem error = ((IWMPMedia2)pMediaObject).Error; + Console.Out.WriteLine($"Media Error {error.errorCode}: {error.errorDescription}"); + Marshal.ReleaseComObject(error); Marshal.ReleaseComObject(pMediaObject); Environment.Exit(Program.CODE_MEDIA_ERROR); } diff --git a/video/Program.cs b/video/Program.cs index c8c9885e..a9d68de1 100644 --- a/video/Program.cs +++ b/video/Program.cs @@ -5,7 +5,7 @@ namespace TweetDuck.Video{ static class Program{ - internal const string Version = "1.2.1.0"; + internal const string Version = "1.2.2.0"; // referenced in VideoPlayer // set by task manager -- public const int CODE_PROCESS_KILLED = 1; @@ -40,7 +40,7 @@ private static int Main(string[] args){ try{ Application.Run(new FormPlayer(ownerHandle, defaultVolume, videoUrl, pipeToken)); }catch(Exception e){ - Console.Out.WriteLine(e.Message); + Console.Out.WriteLine(e); return CODE_LAUNCH_FAIL; }