diff --git a/Core/Other/Media/VideoPlayer.cs b/Core/Other/Media/VideoPlayer.cs index 61fc5b88..5541e5dd 100644 --- a/Core/Other/Media/VideoPlayer.cs +++ b/Core/Other/Media/VideoPlayer.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using System.IO; using System.Windows.Forms; +using TweetDuck.Core.Utils; namespace TweetDuck.Core.Other.Media{ class VideoPlayer{ @@ -9,6 +10,7 @@ class VideoPlayer{ private readonly Form owner; private Process currentProcess; + private string lastUrl; public VideoPlayer(Form owner){ this.owner = owner; @@ -17,6 +19,8 @@ public VideoPlayer(Form owner){ public void Launch(string url){ Close(); + lastUrl = url; + try{ if ((currentProcess = Process.Start(new ProcessStartInfo{ FileName = PlayerExe, @@ -55,11 +59,14 @@ public void Close(){ private void process_Exited(object sender, EventArgs e){ switch(currentProcess.ExitCode){ case 2: // CODE_LAUNCH_FAIL - // TODO + if (FormMessage.Error("Video Playback Error", "Error launching video player, this may be caused by missing Windows Media Player. Do you want to open the video in a browser?", FormMessage.Yes, FormMessage.No)){ + BrowserUtils.OpenExternalBrowser(lastUrl); + } + break; case 3: // CODE_MEDIA_ERROR - // TODO + FormMessage.Error("Video Playback Error", "The video could not be loaded or rendered correctly.", FormMessage.OK); break; } diff --git a/Resources/Scripts/code.js b/Resources/Scripts/code.js index 14c751b7..6633a524 100644 --- a/Resources/Scripts/code.js +++ b/Resources/Scripts/code.js @@ -714,6 +714,7 @@ addRule(".keyboard-shortcut-list { vertical-align: top; }"); // fix keyboard navigation alignment addRule(".account-inline .username { vertical-align: 10%; }"); // move usernames a bit higher addRule(".character-count-compose { width: 40px !important; }"); // fix strangely wide character count element + addRule(".is-video a:not([href*='youtu']) .icon-bg-dot, .is-gif .icon-bg-dot { color: #9f51cf; }"); // change play icon on mp4s addRule(".column-nav-link .attribution { position: absolute; }"); // fix cut off account names addRule(".txt-base-smallest .sprite-verified-mini { width: 13px !important; height: 13px !important; background-position: -223px -99px !important; }"); // fix cut off badge icon when zoomed in @@ -758,9 +759,6 @@ addRule(".js-column-header .column-header-link { padding: 0; }"); // fix column header tooltip hover box addRule(".js-column-header .column-header-link .icon { padding: 9px 4px; width: calc(1em + 8px); height: 100%; box-sizing: border-box; }"); // fix column header tooltip hover box - addRule(".is-video a:not([href*='youtu']), .is-gif .js-media-gif-container { cursor: alias; }"); // change cursor on unsupported videos - addRule(".is-video a:not([href*='youtu']) .icon-bg-dot, .is-gif .icon-bg-dot { color: #bd3d37; }"); // change play icon color on unsupported videos - window.TDGF_reinjectCustomCSS = function(styles){ $("#tweetduck-custom-css").remove(); @@ -826,15 +824,7 @@ let media = this.chirp.getMedia().find(media => media.mediaId === this.clickedMediaEntityId); if (media && media.isVideo && media.service !== "youtube"){ - let data = media.chooseVideoVariant(); - - if (data.content_type === "video/mp4"){ - playVideo(data.url); - } - else{ - $TD.openBrowser(this.clickedLink); - } - + playVideo(media.chooseVideoVariant().url); cancelModal = true; } });