Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
stax76 committed Jul 1, 2019
1 parent d1c5858 commit cedd694
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 24 deletions.
7 changes: 5 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
###
### 4.5

- opening a URL manually no longer uses a input box but uses the clipboard directly
- the manifest was missing the company attribute which caused
Expand All @@ -10,7 +10,10 @@
- a description on how to start mpv.net from Google Chrome was added to the
manual, it's useful to play videos from sites like YouTube, find the
description [here](https://github.com/stax76/mpv.net/blob/master/Manual.md#chrome-extension)

- new config setting remember-height added to remember the window height,
otherwise the video's native resolution is used
- support for protocols other then http added

### 4.4

- clipboard-monitoring was replaced by url-whitelist:
Expand Down
4 changes: 2 additions & 2 deletions mpv.net/Misc/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ public static void open_url(string[] args)
{
MainForm.Instance.Invoke(new Action(() => {
string clipboard = Clipboard.GetText();
if (string.IsNullOrEmpty(clipboard) || !clipboard.Contains("://") || clipboard.Contains("\n") || clipboard.Contains(" "))
if (string.IsNullOrEmpty(clipboard) || (!clipboard.Contains("://") && !File.Exists(clipboard)) || clipboard.Contains("\n"))
{
Msg.ShowError("The clipboard does not contain a valid URL, it has to contain :// and is not allowed to contain a newline or space character.");
Msg.ShowError("The clipboard does not contain a valid URL or file, URLs have to contain :// and is not allowed to contain a newline character.");
return;
}
mp.Load(new [] { clipboard }, false, Control.ModifierKeys.HasFlag(Keys.Control));
Expand Down
2 changes: 1 addition & 1 deletion mpv.net/Misc/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void Main()
List<string> files = new List<string>();

foreach (string arg in args)
if (!arg.StartsWith("--") && (File.Exists(arg) || arg == "-" || arg.StartsWith("http")))
if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") || File.Exists(arg)))
files.Add(arg);

if (files.Count > 0)
Expand Down
4 changes: 2 additions & 2 deletions mpv.net/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.4.0.0")]
[assembly: AssemblyFileVersion("4.4.0.0")]
[assembly: AssemblyVersion("4.5.0.0")]
[assembly: AssemblyFileVersion("4.5.0.0")]
2 changes: 1 addition & 1 deletion mpv.net/Resources/inputConf.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# mpv input keys: https://github.com/stax76/mpv.net/wiki/mpv-input-keys

o script-message mpv.net open-files #menu: Open > Open Files...
u script-message mpv.net open-url #menu: Open > Open URL...
u script-message mpv.net open-url #menu: Open > Open URL or file path from clipboard
_ ignore #menu: Open > -
Alt+a script-message mpv.net load-audio #menu: Open > Load external audio files...
Alt+s script-message mpv.net load-sub #menu: Open > Load external subtitle files...
Expand Down
8 changes: 8 additions & 0 deletions mpv.net/Resources/mpvConfToml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,14 @@ default = "50%"
filter = "Screen"
help = "Set the initial window size in percent. Please note that this setting is only partly implemented in mpv.net, accepted are only integer values with percent sign added. Default: 50%"

[[settings]]
name = "remember-height"
default = "yes"
filter = "Screen"
help = "mpv.net specific setting to remember the window height, otherwise the video's native resolution is used."
options = [{ name = "yes" },
{ name = "no" }]

[[settings]]
name = "keep-open-pause"
default = "yes"
Expand Down
14 changes: 7 additions & 7 deletions mpv.net/Resources/mpvNetConfToml.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
[[settings]]
name = "dark-mode"
default = "always"
filter = "mpv.net"
filter = "General"
help = "Enables a dark theme."
options = [{ name = "always" },
{ name = "system" , help = "Available on Windows 10 or higher" },
{ name = "never" }]

[[settings]]
name = "url-whitelist"
filter = "mpv.net"
filter = "General"
type = "string"
help = "Whitelist to monitor the clipboard for URLs to play.\n\nDefault: tube vimeo ard zdf"
help = "mpv.net specific whitelist setting to monitor the clipboard for URLs to play.\n\nDefault: tube vimeo ard zdf"

[[settings]]
name = "process-instance"
default = "single"
filter = "mpv.net"
help = "Defines if more then one mpv.net process is allowed.\n\nTip: Whenever the control key is pressed when files or URLs are opened, the playlist is not cleared but the files or URLs are appended to the playlist."
filter = "General"
help = "mpv.net specific setting that defines if more then one mpv.net process is allowed.\n\nTip: Whenever the control key is pressed when files or URLs are opened, the playlist is not cleared but the files or URLs are appended to the playlist."
options = [{ name = "multi", help = "Create a new process everytime the shell starts mpv.net" },
{ name = "single", help = "Force a single process everytime the shell starts mpv.net" },
{ name = "queue", help = "Force a single process and add files to playlist" }]

[[settings]]
name = "debug-mode"
default = "no"
filter = "mpv.net"
help = "Writes debug info to a file located on the desktop."
filter = "General"
help = "mpv.net specific setting that writes debug info to a file located on the desktop."
options = [{ name = "yes" },
{ name = "no" }]
11 changes: 6 additions & 5 deletions mpv.net/WinForms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public MainForm()

void CM_Popup(object sender, EventArgs e) => CursorHelp.Show();

void VideoSizeChanged() => BeginInvoke(new Action(() => SetFormPosAndSizeKeepHeight()));
void VideoSizeChanged() => BeginInvoke(new Action(() => SetFormPosAndSize()));

void Shutdown() => BeginInvoke(new Action(() => Close()));

Expand Down Expand Up @@ -222,11 +222,12 @@ void SetStartFormPositionAndSize()
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
}

void SetFormPosAndSizeKeepHeight()
void SetFormPosAndSize()
{
if (IsFullscreen || mp.VideoSize.Width == 0) return;
Screen screen = Screen.FromControl(this);
int height = ClientSize.Height;
int height = mp.VideoSize.Height;
if (mp.RememberHeight) height = ClientSize.Height;
if (height > screen.Bounds.Height * 0.9) height = Convert.ToInt32(screen.Bounds.Height * mp.Autofit);
int width = Convert.ToInt32(height * mp.VideoSize.Width / (double)mp.VideoSize.Height);
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
Expand Down Expand Up @@ -272,7 +273,7 @@ private void FileLoaded()
{
string path = mp.get_property_string("path");
BeginInvoke(new Action(() => {
if (File.Exists(path) || path.StartsWith("http"))
if (File.Exists(path) || path.Contains("://"))
Text = Path.GetFileName(path) + " - mpv.net " + Application.ProductVersion;
else
Text = "mpv.net " + Application.ProductVersion;
Expand Down Expand Up @@ -311,7 +312,7 @@ public void CycleFullscreen(bool enabled)
else
FormBorderStyle = FormBorderStyle.None;

SetFormPosAndSizeKeepHeight();
SetFormPosAndSize();
}
}

Expand Down
9 changes: 5 additions & 4 deletions mpv.net/mpv/mp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ public class mp

public static bool Fullscreen { get; set; }
public static bool Border { get; set; } = true;
public static bool RememberHeight { get; set; } = true;

public static int Screen { get; set; } = -1;
public static int Edition { get; set; }

public static float Autofit { get; set; } = 0.50f;
public static float Autofit { get; set; } = 0.5f;

public static void ProcessProperty(string name, string value)
{
Expand All @@ -91,6 +92,7 @@ public static void ProcessProperty(string name, string value)
case "fullscreen": Fullscreen = value == "yes"; break;
case "border": Border = value == "yes"; break;
case "screen": Screen = Convert.ToInt32(value); break;
case "remember-height": RememberHeight = value == "yes"; break;
}
}

Expand Down Expand Up @@ -524,11 +526,10 @@ protected static void ProcessCommandLine()

foreach (string i in args)
{
if (!i.StartsWith("--") && (i == "-" || i.StartsWith("http") || File.Exists(i)))
if (!i.StartsWith("--") && (i == "-" || i.Contains("://") || File.Exists(i)))
{
files.Add(i);
if (i.StartsWith("http"))
RegHelp.SetObject(App.RegPath, "LastURL", i);
if (i.Contains("://")) RegHelp.SetObject(App.RegPath, "LastURL", i);
}
}

Expand Down

0 comments on commit cedd694

Please sign in to comment.