This commit is contained in:
Frank Skare
2021-04-30 11:50:41 +02:00
parent d0ad69656a
commit 6e2d11952f
24 changed files with 241 additions and 296 deletions

View File

@@ -5,6 +5,10 @@
- Improved window scaling. - Improved window scaling.
- Title property implementation. - Title property implementation.
- Command palette shows commands without assigned menu item. - Command palette shows commands without assigned menu item.
- The code from the included JavaScript file was ported into the core player
because JavaScript is currently broken in the builds of shinshiro.
- MediaInfo 21.3
- libmpv 2021-02-28
5.4.8.7 Beta (2021-03-09) 5.4.8.7 Beta (2021-03-09)

View File

@@ -1,7 +1,7 @@
MIT License MIT License
Copyright (C) 2017-2020 Frank Skare (stax76) Copyright (C) 2017-2021 mpv.net/mpv/mplayer
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and ssociated documentation obtaining a copy of this software and ssociated documentation

View File

@@ -59,19 +59,8 @@ mpv.net requires the .NET Framework 4.8 and Windows 7 or 10 and a modern graphic
There is a setup exe and a portable zip file download. There is a setup exe and a portable zip file download.
x64 editions have the advantage of being typically better optimized and tested.
For internet streaming youtube-dl must be downloaded and installed manually, meaning it must be located in the PATH environment variable or in the startup directory. For internet streaming youtube-dl must be downloaded and installed manually, meaning it must be located in the PATH environment variable or in the startup directory.
### Scoop
If you use Scoop
```
scoop bucket add extras
scoop install mpv.net
```
#### File Associations #### File Associations

View File

@@ -79,7 +79,7 @@ Features
- Fast startup performance - Fast startup performance
- Usable as video player, audio player and image viewer with a wide range of supported formats - Usable as video player, audio player and image viewer with a wide range of supported formats
- Built-in decoders, no external codecs have to be installed - Built-in decoders, no external codecs have to be installed
- Setup as x64, x86, installer, portable, Chocolatey and Scoop - Setup as x64 installer, portable and Chocolatey
- Build-in media streaming (requires youtube-dl being installed) - Build-in media streaming (requires youtube-dl being installed)
- File associations can be created by the setup and from the player - File associations can be created by the setup and from the player
- External audio and subtitle files can be loaded manually or automatically - External audio and subtitle files can be loaded manually or automatically

View File

@@ -1,9 +1,7 @@
$tmpDir = 'D:\Work' $tmpDir = 'D:\Work'
$exePath = $PSScriptRoot + '\mpv.net\bin\x64\mpvnet.exe' $exePath = $PSScriptRoot + '\mpv.net\bin\mpvnet.exe'
$versionInfo = [Diagnostics.FileVersionInfo]::GetVersionInfo($exePath) $versionInfo = [Diagnostics.FileVersionInfo]::GetVersionInfo($exePath)
$vsDir = 'C:\Program Files (x86)\Microsoft Visual Studio\2019'
$msBuild = $vsDir + '\Community\MSBuild\Current\Bin\MSBuild.exe'
$inno = 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe' $inno = 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe'
$7z = 'C:\Program Files\7-Zip\7z.exe' $7z = 'C:\Program Files\7-Zip\7z.exe'
@@ -34,25 +32,11 @@ function UploadBeta($sourceFile)
if ($versionInfo.FilePrivatePart -eq 0) if ($versionInfo.FilePrivatePart -eq 0)
{ {
& $msBuild mpv.net.sln -t:Rebuild -p:Configuration=Debug -p:Platform=x64 & $inno setup.iss
if ($LastExitCode) { throw $LastExitCode } if ($LastExitCode) { throw $LastExitCode }
& $msBuild mpv.net.sln -t:Rebuild -p:Configuration=Debug -p:Platform=x86 $targetDir = $tmpDir + "\mpv.net-$($versionInfo.FileVersion)-portable"
if ($LastExitCode) { throw $LastExitCode } Copy-Item .\mpv.net\bin $targetDir -Recurse -Exclude System.Management.Automation.xml
& $inno /Darch=x64 setup.iss
if ($LastExitCode) { throw $LastExitCode }
& $inno /Darch=x86 setup.iss
if ($LastExitCode) { throw $LastExitCode }
$targetDir = $tmpDir + "\mpv.net-portable-x64-$($versionInfo.FileVersion)"
Copy-Item .\mpv.net\bin\x64 $targetDir -Recurse -Exclude System.Management.Automation.xml
& $7z a -tzip -mx9 "$targetDir.zip" -r "$targetDir\*"
if ($LastExitCode) { throw $LastExitCode }
$targetDir = $tmpDir + "\mpv.net-portable-x86-$($versionInfo.FileVersion)"
Copy-Item .\mpv.net\bin\x86 $targetDir -Recurse -Exclude System.Management.Automation.xml
& $7z a -tzip -mx9 "$targetDir.zip" -r "$targetDir\*" & $7z a -tzip -mx9 "$targetDir.zip" -r "$targetDir\*"
if ($LastExitCode) { throw $LastExitCode } if ($LastExitCode) { throw $LastExitCode }
@@ -62,20 +46,8 @@ if ($versionInfo.FilePrivatePart -eq 0)
} }
else else
{ {
& $msBuild mpv.net.sln -t:Rebuild -p:Configuration=Debug -p:Platform=x64 $targetDir = "$tmpDir\mpv.net-$($versionInfo.FileVersion)-portable-beta"
if ($LastExitCode) { throw $LastExitCode } Copy-Item .\mpv.net\bin $targetDir -Recurse -Exclude System.Management.Automation.xml
& $msBuild mpv.net.sln -t:Rebuild -p:Configuration=Debug -p:Platform=x86
if ($LastExitCode) { throw $LastExitCode }
$targetDir = "$tmpDir\mpv.net-portable-x64-$($versionInfo.FileVersion)-beta"
Copy-Item .\mpv.net\bin\x64 $targetDir -Recurse -Exclude System.Management.Automation.xml
& $7z a -t7z -mx9 "$targetDir.7z" -r "$targetDir\*"
if ($LastExitCode) { throw $LastExitCode }
UploadBeta "$targetDir.7z"
$targetDir = $tmpDir + "\mpv.net-portable-x86-$($versionInfo.FileVersion)-beta"
Copy-Item .\mpv.net\bin\x86 $targetDir -Recurse -Exclude System.Management.Automation.xml
& $7z a -t7z -mx9 "$targetDir.7z" -r "$targetDir\*" & $7z a -t7z -mx9 "$targetDir.7z" -r "$targetDir\*"
if ($LastExitCode) { throw $LastExitCode } if ($LastExitCode) { throw $LastExitCode }
UploadBeta "$targetDir.7z" UploadBeta "$targetDir.7z"

View File

@@ -95,10 +95,21 @@ namespace RatingExtension // the assembly name must end with 'Extension'
else else
{ {
TimeSpan ts = DateTime.Now - DeleteTime; TimeSpan ts = DateTime.Now - DeleteTime;
string path = core.get_property_string("path");
if (FileToDelete == core.get_property_string("path") && ts.TotalSeconds < 5 && File.Exists(FileToDelete)) if (FileToDelete == path && ts.TotalSeconds < 5 && File.Exists(FileToDelete))
{ {
core.command("playlist-remove current"); core.command("playlist-remove current");
int pos = core.get_property_int("playlist-pos");
if (pos == -1)
{
int count = core.get_property_int("playlist-count");
if (count > 0)
core.set_property_int("playlist-pos", count - 1);
}
Thread.Sleep(2000); Thread.Sleep(2000);
FileSystem.DeleteFile(FileToDelete, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin); FileSystem.DeleteFile(FileToDelete, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
} }

View File

@@ -13,39 +13,23 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\mpv.net\bin\x86\Extensions\RatingExtension\</OutputPath> <OutputPath>..\..\mpv.net\bin\Extensions\RatingExtension\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>..\..\mpv.net\bin\x86\Extensions\RatingExtension\</OutputPath> <OutputPath>..\..\mpv.net\bin\Extensions\RatingExtension\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <LangVersion>7.3</LangVersion>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\mpv.net\bin\x64\Extensions\RatingExtension\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>..\..\mpv.net\bin\x64\Extensions\RatingExtension\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>

View File

@@ -13,39 +13,23 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\mpv.net\bin\x86\Extensions\ScriptingExtension\</OutputPath> <OutputPath>..\..\mpv.net\bin\Extensions\ScriptingExtension\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>..\..\mpv.net\bin\x86\Extensions\ScriptingExtension\</OutputPath> <OutputPath>..\..\mpv.net\bin\Extensions\ScriptingExtension\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <LangVersion>7.3</LangVersion>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\mpv.net\bin\x64\Extensions\ScriptingExtension\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>..\..\mpv.net\bin\x64\Extensions\ScriptingExtension\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>

View File

@@ -11,36 +11,22 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptingExtension", "exten
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x64.ActiveCfg = Debug|x64 {1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x64.Build.0 = Debug|x64 {1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x86.ActiveCfg = Debug|x86 {1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x86.Build.0 = Debug|x86 {1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|Any CPU.Build.0 = Release|Any CPU
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x64.ActiveCfg = Release|x64 {55C88710-539D-4402-84C8-31694841C731}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x64.Build.0 = Release|x64 {55C88710-539D-4402-84C8-31694841C731}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x86.ActiveCfg = Release|x86 {55C88710-539D-4402-84C8-31694841C731}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x86.Build.0 = Release|x86 {55C88710-539D-4402-84C8-31694841C731}.Release|Any CPU.Build.0 = Release|Any CPU
{55C88710-539D-4402-84C8-31694841C731}.Debug|x64.ActiveCfg = Debug|x64 {94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55C88710-539D-4402-84C8-31694841C731}.Debug|x64.Build.0 = Debug|x64 {94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55C88710-539D-4402-84C8-31694841C731}.Debug|x86.ActiveCfg = Debug|x86 {94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55C88710-539D-4402-84C8-31694841C731}.Debug|x86.Build.0 = Debug|x86 {94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|Any CPU.Build.0 = Release|Any CPU
{55C88710-539D-4402-84C8-31694841C731}.Release|x64.ActiveCfg = Release|x64
{55C88710-539D-4402-84C8-31694841C731}.Release|x64.Build.0 = Release|x64
{55C88710-539D-4402-84C8-31694841C731}.Release|x86.ActiveCfg = Release|x86
{55C88710-539D-4402-84C8-31694841C731}.Release|x86.Build.0 = Release|x86
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x64.ActiveCfg = Debug|x64
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x64.Build.0 = Debug|x64
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x86.ActiveCfg = Debug|x86
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x86.Build.0 = Debug|x86
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|x64.ActiveCfg = Release|x64
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|x64.Build.0 = Release|x64
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|x86.ActiveCfg = Release|x86
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|x86.Build.0 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -83,7 +83,7 @@ namespace mpvnet
core.Initialized += Initialized; core.Initialized += Initialized;
} }
public static void RunAction(Action action) public static void RunTask(Action action)
{ {
Task.Run(() => { Task.Run(() => {
try { try {
@@ -96,7 +96,7 @@ namespace mpvnet
public static string Version { public static string Version {
get { get {
return "Copyright (C) 2000-2021 mpv.net/mpv/mplayer\n" + return "Copyright (C) 2017-2021 mpv.net/mpv/mplayer\n" +
$"mpv.net {Application.ProductVersion} ({File.GetLastWriteTime(Application.ExecutablePath).ToShortDateString()})\n" + $"mpv.net {Application.ProductVersion} ({File.GetLastWriteTime(Application.ExecutablePath).ToShortDateString()})\n" +
$"{core.get_property_string("mpv-version")} ({File.GetLastWriteTime(Folder.Startup + "mpv-1.dll").ToShortDateString()})\nffmpeg {core.get_property_string("ffmpeg-version")}\nMIT License"; $"{core.get_property_string("mpv-version")} ({File.GetLastWriteTime(Folder.Startup + "mpv-1.dll").ToShortDateString()})\nffmpeg {core.get_property_string("ffmpeg-version")}\nMIT License";
} }

View File

@@ -12,6 +12,7 @@ using VB = Microsoft.VisualBasic;
using static mpvnet.NewLine; using static mpvnet.NewLine;
using static mpvnet.Core; using static mpvnet.Core;
using System.Threading.Tasks;
namespace mpvnet namespace mpvnet
{ {
@@ -48,10 +49,13 @@ namespace mpvnet
case "show-keys": ShowTextWithEditor("input-key-list", core.get_property_string("input-key-list").Replace(",", BR)); break; case "show-keys": ShowTextWithEditor("input-key-list", core.get_property_string("input-key-list").Replace(",", BR)); break;
case "show-media-search": ShowDialog(typeof(EverythingWindow)); break; case "show-media-search": ShowDialog(typeof(EverythingWindow)); break;
case "show-profiles": ShowTextWithEditor("profile-list", mpvHelp.GetProfiles()); break; case "show-profiles": ShowTextWithEditor("profile-list", mpvHelp.GetProfiles()); break;
case "show-playlist": ShowPlaylist(); break;
case "show-properties": ShowProperties(); break; case "show-properties": ShowProperties(); break;
case "show-protocols": ShowTextWithEditor("protocol-list", mpvHelp.GetProtocols()); break; case "show-protocols": ShowTextWithEditor("protocol-list", mpvHelp.GetProtocols()); break;
case "show-setup-dialog": ShowDialog(typeof(SetupWindow)); break; case "show-setup-dialog": ShowDialog(typeof(SetupWindow)); break;
case "show-text": ShowText(args[0], Convert.ToInt32(args[1]), Convert.ToInt32(args[2])); break;
case "update-check": UpdateCheck.CheckOnline(true); break; case "update-check": UpdateCheck.CheckOnline(true); break;
default: Msg.ShowError($"No command '{id}' found."); break; default: Msg.ShowError($"No command '{id}' found."); break;
} }
} }
@@ -161,7 +165,7 @@ namespace mpvnet
{ {
fileSize = new FileInfo(path).Length; fileSize = new FileInfo(path).Length;
if (Core.AudioTypes.Contains(path.Ext())) if (AudioTypes.Contains(path.Ext()))
{ {
using (MediaInfo mediaInfo = new MediaInfo(path)) using (MediaInfo mediaInfo = new MediaInfo(path))
{ {
@@ -185,7 +189,7 @@ namespace mpvnet
return; return;
} }
} }
else if (Core.ImageTypes.Contains(path.Ext())) else if (ImageTypes.Contains(path.Ext()))
{ {
using (MediaInfo mediaInfo = new MediaInfo(path)) using (MediaInfo mediaInfo = new MediaInfo(path))
{ {
@@ -308,7 +312,7 @@ namespace mpvnet
core.commandv("show-text", aid + ": " + tracks[aid - 1].Text.Substring(3), "5000"); core.commandv("show-text", aid + ": " + tracks[aid - 1].Text.Substring(3), "5000");
} }
static void ShowCommands() public static void ShowCommands()
{ {
string code = @" string code = @"
foreach ($item in ($json | ConvertFrom-Json | foreach { $_ } | sort name)) foreach ($item in ($json | ConvertFrom-Json | foreach { $_ } | sort name))
@@ -333,22 +337,54 @@ namespace mpvnet
ShowTextWithEditor("command-list", PowerShell.InvokeAndReturnString(code, "json", json)); ShowTextWithEditor("command-list", PowerShell.InvokeAndReturnString(code, "json", json));
} }
static void ShowProperties() public static void ShowProperties()
{ {
var props = core.get_property_string("property-list").Split(',').OrderBy(prop => prop); var props = core.get_property_string("property-list").Split(',').OrderBy(prop => prop);
ShowTextWithEditor("property-list", string.Join(BR, props)); ShowTextWithEditor("property-list", string.Join(BR, props));
} }
static void ShowTextWithEditor(string name, string text) public static void ShowTextWithEditor(string name, string text)
{ {
string file = Path.GetTempPath() + $"\\{name}.txt"; string file = Path.GetTempPath() + $"\\{name}.txt";
File.WriteAllText(file, BR + text.Trim() + BR); File.WriteAllText(file, BR + text.Trim() + BR);
ProcessHelp.ShellExecute(file); ProcessHelp.ShellExecute(file);
} }
static void ScaleWindow(float factor) public static void ScaleWindow(float factor)
{ {
core.RaiseScaleWindow(factor); core.RaiseScaleWindow(factor);
} }
public static void ShowText(string text, int duration = 0, int fontSize = 0)
{
if (string.IsNullOrEmpty(text))
return;
if (duration == 0)
duration = core.get_property_int("osd-duration");
if (fontSize == 0)
fontSize = core.get_property_int("osd-font-size");
core.command("show-text \"${osd-ass-cc/0}{\\\\fs" + fontSize +
"}${osd-ass-cc/1}" + text + "\" " + duration);
}
public static void ShowPlaylist(string[] args = null)
{
int duration = 5000;
if (args?.Length == 1)
duration = Convert.ToInt32(args[0]);
var size = core.get_property_number("osd-font-size");
core.set_property_number("osd-font-size", 40);
core.command("show-text ${playlist} " + duration);
App.RunTask(() => {
Thread.Sleep(6000);
core.set_property_number("osd-font-size", size);
});
}
} }
} }

View File

@@ -74,13 +74,13 @@ namespace mpvnet
RegistryHelp.SetValue($@"HKCR\" + "." + ext, null, ExeFilenameNoExt + "." + ext); RegistryHelp.SetValue($@"HKCR\" + "." + ext, null, ExeFilenameNoExt + "." + ext);
RegistryHelp.SetValue($@"HKCR\" + "." + ext + @"\OpenWithProgIDs", ExeFilenameNoExt + "." + ext, ""); RegistryHelp.SetValue($@"HKCR\" + "." + ext + @"\OpenWithProgIDs", ExeFilenameNoExt + "." + ext, "");
if (Core.VideoTypes.Contains(ext)) if (VideoTypes.Contains(ext))
RegistryHelp.SetValue(@"HKCR\" + "." + ext, "PerceivedType", "video"); RegistryHelp.SetValue(@"HKCR\" + "." + ext, "PerceivedType", "video");
if (Core.AudioTypes.Contains(ext)) if (AudioTypes.Contains(ext))
RegistryHelp.SetValue(@"HKCR\" + "." + ext, "PerceivedType", "audio"); RegistryHelp.SetValue(@"HKCR\" + "." + ext, "PerceivedType", "audio");
if (Core.ImageTypes.Contains(ext)) if (ImageTypes.Contains(ext))
RegistryHelp.SetValue(@"HKCR\" + "." + ext, "PerceivedType", "image"); RegistryHelp.SetValue(@"HKCR\" + "." + ext, "PerceivedType", "image");
RegistryHelp.SetValue($@"HKCR\" + ExeFilenameNoExt + "." + ext + @"\shell\open\command", null, $"\"{ExePath}\" \"%1\""); RegistryHelp.SetValue($@"HKCR\" + ExeFilenameNoExt + "." + ext + @"\shell\open\command", null, $"\"{ExePath}\" \"%1\"");

View File

@@ -19,7 +19,7 @@ namespace mpvnet
public bool Print { get; set; } public bool Print { get; set; }
public List<string> Scripts { get; } = new List<string>(); public List<string> Scripts { get; } = new List<string>();
public List<KeyValuePair<string, object>> Variables = new List<KeyValuePair<string, object>>(); public List<KeyValuePair<string, object>> Variables = new List<KeyValuePair<string, object>>();
public string[] Parameters { get; } public string[] Arguments { get; }
public event Action<string, object[]> Event; public event Action<string, object[]> Event;
public event Action<string, object> PropertyChanged; public event Action<string, object> PropertyChanged;
public List<KeyValuePair<string, ScriptBlock>> EventHandlers = new List<KeyValuePair<string, ScriptBlock>>(); public List<KeyValuePair<string, ScriptBlock>> EventHandlers = new List<KeyValuePair<string, ScriptBlock>>();
@@ -41,8 +41,8 @@ namespace mpvnet
foreach (string script in Scripts) foreach (string script in Scripts)
Pipeline.Commands.AddScript(script); Pipeline.Commands.AddScript(script);
if (Parameters != null) if (Arguments != null)
foreach (string param in Parameters) foreach (string param in Arguments)
foreach (Command command in Pipeline.Commands) foreach (Command command in Pipeline.Commands)
command.Parameters.Add(null, param); command.Parameters.Add(null, param);
@@ -137,19 +137,19 @@ namespace mpvnet
switch (type) switch (type)
{ {
case "bool": case "boolean": case "bool": case "boolean":
core.observe_property_bool(name, (value) => App.RunAction(() => PropertyChanged.Invoke(name, value))); core.observe_property_bool(name, (value) => App.RunTask(() => PropertyChanged.Invoke(name, value)));
break; break;
case "string": case "string":
core.observe_property_string(name, (value) => App.RunAction(() => PropertyChanged.Invoke(name, value))); core.observe_property_string(name, (value) => App.RunTask(() => PropertyChanged.Invoke(name, value)));
break; break;
case "int": case "integer": case "int": case "integer":
core.observe_property_int(name, (value) => App.RunAction(() => PropertyChanged.Invoke(name, value))); core.observe_property_int(name, (value) => App.RunTask(() => PropertyChanged.Invoke(name, value)));
break; break;
case "float": case "double": case "float": case "double":
core.observe_property_double(name, (value) => App.RunAction(() => PropertyChanged.Invoke(name, value))); core.observe_property_double(name, (value) => App.RunTask(() => PropertyChanged.Invoke(name, value)));
break; break;
case "nil": case "none": case "native": case "nil": case "none": case "native":
core.observe_property(name, () => App.RunAction(() => PropertyChanged.Invoke(name, null))); core.observe_property(name, () => App.RunTask(() => PropertyChanged.Invoke(name, null)));
break; break;
default: default:
App.ShowError("Invalid Type", "Valid types are: bool or boolean, string, int or integer, float or double, nil or none or native"); App.ShowError("Invalid Type", "Valid types are: bool or boolean, string, int or integer, float or double, nil or none or native");

View File

@@ -32,7 +32,7 @@ namespace mpvnet
var response = await client.GetAsync("https://api.github.com/repos/stax76/mpv.net/releases/latest"); var response = await client.GetAsync("https://api.github.com/repos/stax76/mpv.net/releases/latest");
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
string content = await response.Content.ReadAsStringAsync(); string content = await response.Content.ReadAsStringAsync();
Match match = Regex.Match(content, @"""mpv\.net-([\d\.]+)-portable-x64\.zip"""); Match match = Regex.Match(content, @"""mpv\.net-([\d\.]+)-portable\.zip""");
Version onlineVersion = Version.Parse(match.Groups[1].Value); Version onlineVersion = Version.Parse(match.Groups[1].Value);
Version currentVersion = Assembly.GetEntryAssembly().GetName().Version; Version currentVersion = Assembly.GetEntryAssembly().GetName().Version;
@@ -48,15 +48,14 @@ namespace mpvnet
!= onlineVersion.ToString() || showUpToDateMessage) && Msg.ShowQuestion( != onlineVersion.ToString() || showUpToDateMessage) && Msg.ShowQuestion(
$"New version {onlineVersion} is available, update now?") == MsgResult.OK) $"New version {onlineVersion} is available, update now?") == MsgResult.OK)
{ {
string arch = IntPtr.Size == 8 ? "64" : "86"; string url = $"https://github.com/stax76/mpv.net/releases/download/{onlineVersion}/mpv.net-{onlineVersion}-portable.zip";
string url = $"https://github.com/stax76/mpv.net/releases/download/{onlineVersion}/mpv.net-{onlineVersion}-portable-x{arch}.zip";
using (Process proc = new Process()) using (Process proc = new Process())
{ {
proc.StartInfo.UseShellExecute = true; proc.StartInfo.UseShellExecute = true;
proc.StartInfo.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); proc.StartInfo.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
proc.StartInfo.FileName = "powershell.exe"; proc.StartInfo.FileName = "powershell.exe";
proc.StartInfo.Arguments = $"-NoLogo -NoExit -File \"{Folder.Startup + "Setup\\update.ps1"}\" \"{url}\" \"{Folder.Startup.TrimEnd(Path.DirectorySeparatorChar)}\""; proc.StartInfo.Arguments = $"-NoExit -ExecutionPolicy Bypass -File \"{Folder.Startup + "Setup\\update.ps1"}\" \"{url}\" \"{Folder.Startup.TrimEnd(Path.DirectorySeparatorChar)}\"";
if (Folder.Startup.Contains("Program Files")) if (Folder.Startup.Contains("Program Files"))
proc.StartInfo.Verb = "runas"; proc.StartInfo.Verb = "runas";

View File

@@ -462,18 +462,20 @@ public class TaskDialog<T> : TaskDialogNative, IDisposable
{ {
if (Buttons != null && Buttons.Count > 0) if (Buttons != null && Buttons.Count > 0)
{ {
ButtonArray = TaskDialog<T>.AllocateAndMarshalButtons(Buttons); ButtonArray = AllocateAndMarshalButtons(Buttons);
Config.pButtons = ButtonArray; Config.pButtons = ButtonArray;
Config.cButtons = (uint)Buttons.Count; Config.cButtons = (uint)Buttons.Count;
} }
if (RadioButtons == null || RadioButtons.Count <= 0) return; if (RadioButtons == null || RadioButtons.Count <= 0)
RadioButtonArray = TaskDialog<T>.AllocateAndMarshalButtons(RadioButtons); return;
RadioButtonArray = AllocateAndMarshalButtons(RadioButtons);
Config.pRadioButtons = RadioButtonArray; Config.pRadioButtons = RadioButtonArray;
Config.cRadioButtons = (uint)RadioButtons.Count; Config.cRadioButtons = (uint)RadioButtons.Count;
} }
public static IntPtr AllocateAndMarshalButtons(List<TaskDialogNative.TASKDIALOG_BUTTON> structs) public static IntPtr AllocateAndMarshalButtons(List<TASKDIALOG_BUTTON> structs)
{ {
var initialPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(TASKDIALOG_BUTTON)) * structs.Count); var initialPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(TASKDIALOG_BUTTON)) * structs.Count);
var currentPtr = initialPtr; var currentPtr = initialPtr;

View File

@@ -23,7 +23,7 @@ public class Taskbar
// ITaskbarList2 // ITaskbarList2
[PreserveSig] void MarkFullscreenWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fFullscreen); [PreserveSig] void MarkFullscreenWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
// ITaskbarList3 // ITaskbarList3
[PreserveSig] void SetProgressValue(IntPtr hwnd, UInt64 ullCompleted, UInt64 ullTotal); [PreserveSig] void SetProgressValue(IntPtr hwnd, ulong ullCompleted, ulong ullTotal);
[PreserveSig] void SetProgressState(IntPtr hwnd, TaskbarStates state); [PreserveSig] void SetProgressState(IntPtr hwnd, TaskbarStates state);
} }
@@ -41,7 +41,7 @@ public class Taskbar
public void SetValue(double progressValue, double progressMax) public void SetValue(double progressValue, double progressMax)
{ {
Instance.SetProgressValue(Handle, (UInt64)progressValue, (UInt64)progressMax); Instance.SetProgressValue(Handle, (ulong)progressValue, (ulong)progressMax);
} }
} }

View File

@@ -56,11 +56,11 @@
. frame-step #menu: Navigate > Jump Next Frame . frame-step #menu: Navigate > Jump Next Frame
, frame-back-step #menu: Navigate > Jump Previous Frame , frame-back-step #menu: Navigate > Jump Previous Frame
_ ignore #menu: Navigate > - _ ignore #menu: Navigate > -
Right seek 7 #menu: Navigate > Jump 7 sec forward Right seek 5 #menu: Navigate > Jump 5 sec forward
Left seek -7 #menu: Navigate > Jump 7 sec backward Left seek -5 #menu: Navigate > Jump 5 sec backward
_ ignore #menu: Navigate > - _ ignore #menu: Navigate > -
Up seek 40 #menu: Navigate > Jump 40 sec forward Up seek 30 #menu: Navigate > Jump 30 sec forward
Down seek -40 #menu: Navigate > Jump 40 sec backward Down seek -30 #menu: Navigate > Jump 30 sec backward
_ ignore #menu: Navigate > - _ ignore #menu: Navigate > -
Ctrl+Right seek 300 #menu: Navigate > Jump 5 min forward Ctrl+Right seek 300 #menu: Navigate > Jump 5 min forward
Ctrl+Left seek -300 #menu: Navigate > Jump 5 min backward Ctrl+Left seek -300 #menu: Navigate > Jump 5 min backward
@@ -158,7 +158,7 @@
_ script-message mpv.net show-decoders #menu: View > Show Decoders _ script-message mpv.net show-decoders #menu: View > Show Decoders
_ script-message mpv.net show-demuxers #menu: View > Show Demuxers _ script-message mpv.net show-demuxers #menu: View > Show Demuxers
_ script-message mpv.net show-keys #menu: View > Show Keys _ script-message mpv.net show-keys #menu: View > Show Keys
F8 script-binding show-playlist #menu: View > Show Playlist F8 script-message mpv.net show-playlist #menu: View > Show Playlist
Ctrl+p script-message mpv.net show-profiles #menu: View > Show Profiles Ctrl+p script-message mpv.net show-profiles #menu: View > Show Profiles
p show-progress #menu: View > Show Progress p show-progress #menu: View > Show Progress
Shift+p script-message mpv.net show-properties #menu: View > Show Properties Shift+p script-message mpv.net show-properties #menu: View > Show Properties

View File

@@ -11,6 +11,7 @@
Width="400" Width="400"
FontSize="13" FontSize="13"
ResizeMode="NoResize" ResizeMode="NoResize"
ShowInTaskbar="False"
WindowStartupLocation="CenterOwner" WindowStartupLocation="CenterOwner"
Loaded="Window_Loaded"> Loaded="Window_Loaded">

View File

@@ -119,7 +119,7 @@ namespace mpvnet
void FilterTextBox_TextChanged(object sender, TextChangedEventArgs e) void FilterTextBox_TextChanged(object sender, TextChangedEventArgs e)
{ {
string searchtext = FilterTextBox.Text; string searchtext = FilterTextBox.Text;
App.RunAction(() => Search(searchtext)); App.RunTask(() => Search(searchtext));
} }
object LockObject = new object(); object LockObject = new object();

View File

@@ -953,8 +953,8 @@ namespace mpvnet
protected override void OnKeyDown(KeyEventArgs e) protected override void OnKeyDown(KeyEventArgs e)
{ {
// prevent beep using alt key // prevent annoying beep using alt key
if (Control.ModifierKeys == Keys.Alt) if (ModifierKeys == Keys.Alt)
e.SuppressKeyPress = true; e.SuppressKeyPress = true;
base.OnKeyDown(e); base.OnKeyDown(e);

View File

@@ -33,47 +33,28 @@
<PropertyGroup> <PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\</OutputPath> <OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<LangVersion>7.3</LangVersion> <LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\x86\</OutputPath> <OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<LangVersion>7.3</LangVersion> <LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> <Prefer32Bit>false</Prefer32Bit>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.VisualBasic" /> <Reference Include="Microsoft.VisualBasic" />

View File

@@ -103,12 +103,12 @@ namespace mpvnet
public string Title { get; set; } = ""; public string Title { get; set; } = "";
public string Vid { get; set; } = ""; public string Vid { get; set; } = "";
public bool WasInitialSizeSet;
public bool Border { get; set; } = true; public bool Border { get; set; } = true;
public bool Fullscreen { get; set; } public bool Fullscreen { get; set; }
public bool IsLogoVisible { set; get; } public bool IsLogoVisible { set; get; }
public bool IsQuitNeeded { set; get; } = true; public bool IsQuitNeeded { set; get; } = true;
public bool TaskbarProgress { get; set; } = true; public bool TaskbarProgress { get; set; } = true;
public bool WasInitialSizeSet;
public bool WindowMaximized { get; set; } public bool WindowMaximized { get; set; }
public bool WindowMinimized { get; set; } public bool WindowMinimized { get; set; }
@@ -129,7 +129,7 @@ namespace mpvnet
mpv_request_log_messages(Handle, "terminal-default"); mpv_request_log_messages(Handle, "terminal-default");
App.RunAction(() => EventLoop()); App.RunTask(() => EventLoop());
if (App.IsStartedFromTerminal) if (App.IsStartedFromTerminal)
{ {
@@ -152,8 +152,6 @@ namespace mpvnet
Initialized?.Invoke(); Initialized?.Invoke();
InvokeAsync(InitializedAsync); InvokeAsync(InitializedAsync);
LoadMpvScripts();
} }
public void ProcessProperty(string name, string value) public void ProcessProperty(string name, string value)
@@ -287,37 +285,11 @@ namespace mpvnet
} }
} }
public void LoadMpvScripts()
{
if (Directory.Exists(Folder.Startup + "Scripts"))
foreach (string path in Directory.GetFiles(Folder.Startup + "Scripts"))
if ((path.EndsWith(".lua") || path.EndsWith(".js")) && KnownScripts.Contains(Path.GetFileName(path)))
commandv("load-script", $"{path}");
}
public string[] KnownScripts { get; } = { "show-playlist.js"};
public void LoadScripts() public void LoadScripts()
{ {
if (Directory.Exists(Folder.Startup + "Scripts"))
{
foreach (string file in Directory.GetFiles(Folder.Startup + "Scripts"))
{
if (KnownScripts.Contains(Path.GetFileName(file)))
{
if (file.EndsWith(".ps1"))
App.RunAction(() => InvokePowerShellScript(file));
}
else
ConsoleHelp.WriteError("Failed to load script:\n" + file +
"\nOnly scripts that ship with mpv.net are allowed in <startup>\\scripts." +
"\nNever copy or install a new mpv.net version on top of a old mpv.net version.");
}
}
if (Directory.Exists(ConfigFolder + "scripts-ps")) if (Directory.Exists(ConfigFolder + "scripts-ps"))
foreach (string file in Directory.GetFiles(ConfigFolder + "scripts-ps", "*.ps1")) foreach (string file in Directory.GetFiles(ConfigFolder + "scripts-ps", "*.ps1"))
App.RunAction(() => InvokePowerShellScript(file)); App.RunTask(() => InvokePowerShellScript(file));
} }
public void InvokePowerShellScript(string file) public void InvokePowerShellScript(string file)
@@ -425,7 +397,7 @@ namespace mpvnet
string[] args = ConvertFromUtf8Strings(data.args, data.num_args); string[] args = ConvertFromUtf8Strings(data.args, data.num_args);
if (args.Length > 1 && args[0] == "mpv.net") if (args.Length > 1 && args[0] == "mpv.net")
App.RunAction(() => Commands.Execute(args[1], args.Skip(2).ToArray())); App.RunTask(() => Commands.Execute(args[1], args.Skip(2).ToArray()));
InvokeAsync<string[]>(ClientMessageAsync, args); InvokeAsync<string[]>(ClientMessageAsync, args);
ClientMessage?.Invoke(args); ClientMessage?.Invoke(args);
@@ -473,9 +445,9 @@ namespace mpvnet
VideoSizeAutoResetEvent.Set(); VideoSizeAutoResetEvent.Set();
App.RunAction(new Action(() => ReadMetaData())); App.RunTask(new Action(() => ReadMetaData()));
App.RunAction(new Action(() => { App.RunTask(new Action(() => {
string path = core.get_property_string("path"); string path = core.get_property_string("path");
if (path.Contains("://")) if (path.Contains("://"))
@@ -641,7 +613,7 @@ namespace mpvnet
foreach (Action a in action.GetInvocationList()) foreach (Action a in action.GetInvocationList())
{ {
var a2 = a; var a2 = a;
App.RunAction(a2); App.RunTask(a2);
} }
} }
} }
@@ -653,7 +625,7 @@ namespace mpvnet
foreach (Action<T> a in action.GetInvocationList()) foreach (Action<T> a in action.GetInvocationList())
{ {
var a2 = a; var a2 = a;
App.RunAction(() => a2.Invoke(t)); App.RunTask(() => a2.Invoke(t));
} }
} }
} }
@@ -665,7 +637,7 @@ namespace mpvnet
foreach (Action<T1, T2> a in action.GetInvocationList()) foreach (Action<T1, T2> a in action.GetInvocationList())
{ {
var a2 = a; var a2 = a;
App.RunAction(() => a2.Invoke(t1, t2)); App.RunTask(() => a2.Invoke(t1, t2));
} }
} }
} }
@@ -676,20 +648,6 @@ namespace mpvnet
IsLogoVisible = false; IsLogoVisible = false;
} }
public void commandv(params string[] args)
{
IntPtr mainPtr = AllocateUtf8ArrayWithSentinel(args, out IntPtr[] byteArrayPointers);
mpv_error err = mpv_command(Handle, mainPtr);
foreach (IntPtr ptr in byteArrayPointers)
Marshal.FreeHGlobal(ptr);
Marshal.FreeHGlobal(mainPtr);
if (err < 0)
HandleError(err, true, "error executing command:", string.Join("\n", args));
}
public void command(string command, bool throwException = false) public void command(string command, bool throwException = false)
{ {
mpv_error err = mpv_command_string(Handle, command); mpv_error err = mpv_command_string(Handle, command);
@@ -698,6 +656,70 @@ namespace mpvnet
HandleError(err, throwException, "error executing command:", command); HandleError(err, throwException, "error executing command:", command);
} }
public void commandv(params string[] args)
{
int count = args.Length + 1;
IntPtr[] pointers = new IntPtr[count];
IntPtr rootPtr = Marshal.AllocHGlobal(IntPtr.Size * count);
for (int index = 0; index < args.Length; index++)
{
var bytes = GetUtf8Bytes(args[index]);
IntPtr ptr = Marshal.AllocHGlobal(bytes.Length);
Marshal.Copy(bytes, 0, ptr, bytes.Length);
pointers[index] = ptr;
}
Marshal.Copy(pointers, 0, rootPtr, count);
mpv_error err = mpv_command(Handle, rootPtr);
foreach (IntPtr ptr in pointers)
Marshal.FreeHGlobal(ptr);
Marshal.FreeHGlobal(rootPtr);
if (err < 0)
HandleError(err, true, "error executing command:", string.Join("\n", args));
}
public string expand(string value)
{
string[] args = { "expand-text", value };
int count = args.Length + 1;
IntPtr[] pointers = new IntPtr[count];
IntPtr rootPtr = Marshal.AllocHGlobal(IntPtr.Size * count);
for (int index = 0; index < args.Length; index++)
{
var bytes = GetUtf8Bytes(args[index]);
IntPtr ptr = Marshal.AllocHGlobal(bytes.Length);
Marshal.Copy(bytes, 0, ptr, bytes.Length);
pointers[index] = ptr;
}
Marshal.Copy(pointers, 0, rootPtr, count);
IntPtr resultNodePtr = Marshal.AllocHGlobal(16);
mpv_error err = mpv_command_ret(Handle, rootPtr, resultNodePtr);
foreach (IntPtr ptr in pointers)
Marshal.FreeHGlobal(ptr);
Marshal.FreeHGlobal(rootPtr);
if (err < 0)
{
HandleError(err, true, "error executing command:", string.Join("\n", args));
Marshal.FreeHGlobal(resultNodePtr);
return "property expansion error";
}
mpv_node resultNode = Marshal.PtrToStructure<mpv_node>(resultNodePtr);
string ret = ConvertFromUtf8(resultNode.str);
mpv_free_node_contents(resultNodePtr);
Marshal.FreeHGlobal(resultNodePtr);
return ret;
}
public bool get_property_bool(string name, bool throwException = false) public bool get_property_bool(string name, bool throwException = false)
{ {
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
@@ -711,7 +733,7 @@ namespace mpvnet
public void set_property_bool(string name, bool value, bool throwException = false) public void set_property_bool(string name, bool value, bool throwException = false)
{ {
Int64 val = (value) ? 1 : 0; long val = (value) ? 1 : 0;
mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_FLAG, ref val); mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_FLAG, ref val);
if (err < 0) if (err < 0)
@@ -731,7 +753,7 @@ namespace mpvnet
public void set_property_int(string name, int value, bool throwException = false) public void set_property_int(string name, int value, bool throwException = false)
{ {
Int64 val = value; long val = value;
mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref val); mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref val);
if (err < 0) if (err < 0)
@@ -917,18 +939,6 @@ namespace mpvnet
} }
} }
public void show_text(string text, int duration = 0, int fontSize = 0)
{
if (duration == 0)
duration = get_property_int("osd-duration");
if (fontSize == 0)
fontSize = get_property_int("osd-font-size");
core.command("show-text \"${osd-ass-cc/0}{\\\\fs" + fontSize +
"}${osd-ass-cc/1}" + text + "\" " + duration);
}
public void HandleError(mpv_error err, bool throwException, params string[] messages) public void HandleError(mpv_error err, bool throwException, params string[] messages)
{ {
if (throwException) if (throwException)
@@ -1106,7 +1116,7 @@ namespace mpvnet
set_property_int("playlist-pos", 0); set_property_int("playlist-pos", 0);
if (loadFolder && !append) if (loadFolder && !append)
App.RunAction(() => LoadFolder()); App.RunTask(() => LoadFolder());
} }
public void LoadISO(string path) public void LoadISO(string path)

View File

@@ -17,6 +17,12 @@ public class libmpv
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern mpv_error mpv_command_string(IntPtr mpvHandle, [MarshalAs(UnmanagedType.LPUTF8Str)] string command); public static extern mpv_error mpv_command_string(IntPtr mpvHandle, [MarshalAs(UnmanagedType.LPUTF8Str)] string command);
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern mpv_error mpv_command_ret(IntPtr mpvHandle, IntPtr strings, IntPtr node);
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void mpv_free_node_contents(IntPtr node);
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr mpv_error_string(mpv_error error); public static extern IntPtr mpv_error_string(mpv_error error);
@@ -42,16 +48,16 @@ public class libmpv
public static extern mpv_error mpv_set_property(IntPtr mpvHandle, byte[] name, mpv_format format, ref byte[] data); public static extern mpv_error mpv_set_property(IntPtr mpvHandle, byte[] name, mpv_format format, ref byte[] data);
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern mpv_error mpv_set_property(IntPtr mpvHandle, byte[] name, mpv_format format, ref Int64 data); public static extern mpv_error mpv_set_property(IntPtr mpvHandle, byte[] name, mpv_format format, ref long data);
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern mpv_error mpv_set_property(IntPtr mpvHandle, byte[] name, mpv_format format, ref double data); public static extern mpv_error mpv_set_property(IntPtr mpvHandle, byte[] name, mpv_format format, ref double data);
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern mpv_error mpv_observe_property(IntPtr mpvHandle, UInt64 reply_userdata, [MarshalAs(UnmanagedType.LPUTF8Str)] string name, mpv_format format); public static extern mpv_error mpv_observe_property(IntPtr mpvHandle, ulong reply_userdata, [MarshalAs(UnmanagedType.LPUTF8Str)] string name, mpv_format format);
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int mpv_unobserve_property(IntPtr mpvHandle, UInt64 registered_reply_userdata); public static extern int mpv_unobserve_property(IntPtr mpvHandle, ulong registered_reply_userdata);
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void mpv_free(IntPtr data); public static extern void mpv_free(IntPtr data);
@@ -163,7 +169,7 @@ public class libmpv
{ {
public mpv_event_id event_id; public mpv_event_id event_id;
public int error; public int error;
public UInt64 reply_userdata; public ulong reply_userdata;
public IntPtr data; public IntPtr data;
} }
@@ -189,22 +195,16 @@ public class libmpv
public int error; public int error;
} }
public static IntPtr AllocateUtf8ArrayWithSentinel(string[] arr, out IntPtr[] byteArrayPointers) [StructLayout(LayoutKind.Explicit, Size = 16)]
public struct mpv_node
{ {
int numberOfStrings = arr.Length + 1; // add extra element for extra null pointer last (sentinel) [FieldOffset(0)] public IntPtr str;
byteArrayPointers = new IntPtr[numberOfStrings]; [FieldOffset(0)] public int flag;
IntPtr rootPointer = Marshal.AllocCoTaskMem(IntPtr.Size * numberOfStrings); [FieldOffset(0)] public long int64;
[FieldOffset(0)] public double dbl;
for (int index = 0; index < arr.Length; index++) [FieldOffset(0)] public IntPtr list;
{ [FieldOffset(0)] public IntPtr ba;
var bytes = GetUtf8Bytes(arr[index]); [FieldOffset(8)] public mpv_format format;
IntPtr unmanagedPointer = Marshal.AllocHGlobal(bytes.Length);
Marshal.Copy(bytes, 0, unmanagedPointer, bytes.Length);
byteArrayPointers[index] = unmanagedPointer;
}
Marshal.Copy(byteArrayPointers, 0, rootPointer, numberOfStrings);
return rootPointer;
} }
public static string[] ConvertFromUtf8Strings(IntPtr utf8StringArray, int stringCount) public static string[] ConvertFromUtf8Strings(IntPtr utf8StringArray, int stringCount)

View File

@@ -1,32 +1,18 @@
#define MyAppName "mpv.net" #define MyAppName "mpv.net"
#define MyAppExeName "mpvnet.exe" #define MyAppExeName "mpvnet.exe"
#define MyAppSourceDir "mpv.net\bin"
#ifndef arch #define MyAppVersion GetFileVersion("mpv.net\bin\mpvnet.exe")
#define arch "x64"
#endif
#if arch == "x64"
#define MyAppSourceDir "mpv.net\bin\x64"
#define MyAppVersion GetFileVersion("mpv.net\bin\x64\mpvnet.exe")
#else
#define MyAppSourceDir "mpv.net\bin\x86"
#define MyAppVersion GetFileVersion("mpv.net\bin\x86\mpvnet.exe")
#endif
[Setup] [Setup]
AppId={{9AA2B100-BEF3-44D0-B819-D8FC3C4D557D}} AppId={{9AA2B100-BEF3-44D0-B819-D8FC3C4D557D}}
AppName={#MyAppName} AppName={#MyAppName}
AppVersion={#MyAppVersion} AppVersion={#MyAppVersion}
AppPublisher=Frank Skare (stax76) AppPublisher=Frank Skare (stax76)
ArchitecturesInstallIn64BitMode=x64
#if arch == "x64"
ArchitecturesInstallIn64BitMode=x64
#endif
Compression=lzma2 Compression=lzma2
DefaultDirName={commonpf}\{#MyAppName} DefaultDirName={commonpf}\{#MyAppName}
OutputBaseFilename=mpv.net-{#MyAppVersion}-setup-{#arch} OutputBaseFilename=mpv.net-{#MyAppVersion}-setup
OutputDir={#GetEnv('USERPROFILE')}\Desktop OutputDir={#GetEnv('USERPROFILE')}\Desktop
DefaultGroupName={#MyAppName} DefaultGroupName={#MyAppName}
SetupIconFile=mpv.net\mpvnet.ico SetupIconFile=mpv.net\mpvnet.ico
@@ -40,6 +26,6 @@ Source: "{#MyAppSourceDir}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignorevers
Source: "{#MyAppSourceDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Source: "{#MyAppSourceDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs;
[UninstallRun] [UninstallRun]
Filename: "powershell.exe"; Flags: runhidden; Parameters: "-ExecutionPolicy Bypass -File ""{app}\Setup\remove file associations.ps1""" Filename: "powershell.exe"; Flags: runhidden; Parameters: "-NoProfile -ExecutionPolicy Bypass -File ""{app}\Setup\remove file associations.ps1"""
Filename: "powershell.exe"; Flags: runhidden; Parameters: "-ExecutionPolicy Bypass -File ""{app}\Setup\remove start menu shortcut.ps1""" Filename: "powershell.exe"; Flags: runhidden; Parameters: "-NoProfile -ExecutionPolicy Bypass -File ""{app}\Setup\remove start menu shortcut.ps1"""
Filename: "powershell.exe"; Flags: runhidden; Parameters: "-ExecutionPolicy Bypass -File ""{app}\Setup\remove environment variable.ps1""" Filename: "powershell.exe"; Flags: runhidden; Parameters: "-NoProfile -ExecutionPolicy Bypass -File ""{app}\Setup\remove environment variable.ps1"""