Skip to content

Commit

Permalink
New menu item added to add mpv.net to the path environment variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
stax76 committed Dec 13, 2023
1 parent 3eb4af5 commit 35b17bc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

# v7.0.0.3 Beta (2023-??-??)

- New menu item added at Settings/Setup to add mpv.net to the path environment variable.

# v7.0.0.2 Beta (2023-12-13)

- Besides a portable download there is now again a setup installer.
Expand Down
3 changes: 3 additions & 0 deletions docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ mpv.net specific commands

mpv.net commands are used when mpv commands don't exist or lack a feature.

### add-to-path
Adds mpv.net to the Path environment variable.

### load-audio
Shows a file browser dialog to open external audio files.

Expand Down
18 changes: 18 additions & 0 deletions src/MpvNet.Windows/GuiCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class GuiCommand
["show-menu"] = args => ShowMenu?.Invoke(),
["show-bindings"] = args => ShowBindings(),
["show-playlist"] = args => ShowPlaylist(),
["add-to-path"] = args => AddToPath(),


// deprecated
Expand Down Expand Up @@ -263,6 +264,23 @@ public void ShowMediaInfo(IList<string> args)

public void ShowBindings() => Command.ShowTextWithEditor("Bindings", Player.UsedInputConfContent);

public void AddToPath()
{
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)!;

if (path.ToLower().Contains(Folder.Startup.TrimEnd(Path.DirectorySeparatorChar).ToLower()))
{
Msg.ShowWarning("mpv.net is already in Path.");
return;
}

Environment.SetEnvironmentVariable("Path",
Folder.Startup.TrimEnd(Path.DirectorySeparatorChar) + ";" + path,
EnvironmentVariableTarget.User);

Msg.ShowInfo("mpv.net successfully was added to Path.");
}

public void ShowPlaylist()
{
var count = Player.GetPropertyInt("playlist-count");
Expand Down
1 change: 1 addition & 0 deletions src/MpvNet/InputHelp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public static List<Binding> GetDefaults()
new (_("Settings") + " > " + _("Setup"), _("Register audio file associations"), "script-message-to mpvnet reg-file-assoc audio"),
new (_("Settings") + " > " + _("Setup"), _("Register image file associations"), "script-message-to mpvnet reg-file-assoc image"),
new (_("Settings") + " > " + _("Setup"), _("Unregister file associations"), "script-message-to mpvnet reg-file-assoc unreg"),
new (_("Settings") + " > " + _("Setup"), _("Add mpv.net to Path environment variable"), "script-message-to mpvnet add-to-path"),

new (_("Tools"), _("Set/clear A-B loop points"), "ab-loop", "l"),
new (_("Tools"), _("Toggle infinite file looping"), "cycle-values loop-file inf no", "L"),
Expand Down

0 comments on commit 35b17bc

Please sign in to comment.