Compare commits

...

9 Commits

Author SHA1 Message Date
Frank Skare
e31284171c 0.2.3 2018-12-19 23:35:16 +01:00
Frank Skare
f115a5cf3a 0.2.3 2018-12-19 23:28:38 +01:00
stax76
5e3e734245 - 2018-05-28 22:18:34 +02:00
stax76
0cf38669a0 0.2.2 2017-10-04 06:08:59 +02:00
stax76
f5c7864771 0.2.1 2017-09-19 23:08:35 +02:00
stax76
3c12d8a7da - 2017-09-03 11:28:38 +02:00
stax76
0b6f12198b - 2017-09-02 05:45:19 +02:00
stax76
215718dd63 - 2017-09-02 05:42:25 +02:00
stax76
1bbaae873a - 2017-09-02 05:29:38 +02:00
26 changed files with 356 additions and 286 deletions

View File

@@ -1,20 +1,4 @@
' mpv.net
' Copyright(C) 2017 stax76
'
' This program Is free software: you can redistribute it And/Or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, Or
' (at your option) any later version.
'
' This program Is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE.See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If Not, see http://www.gnu.org/licenses/.
Imports System.ComponentModel.Composition
Imports System.ComponentModel.Composition
Imports System.IO
Imports vbnet
@@ -29,12 +13,11 @@ Public Class CSScriptAddon
Sub New()
Dim scriptDir = Folder.AppDataRoaming + "mpv\scripts"
If Not Directory.Exists(scriptDir) Then Return
Dim csxFiles = Directory.GetFiles(scriptDir, "*.cs")
If csxFiles.Count = 0 Then Return
Dim csFiles = Directory.GetFiles(scriptDir, "*.cs")
If csFiles.Count = 0 Then Return
CSScriptLibrary.CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom
CSScriptLibrary.CSScript.Evaluator.ReferenceDomainAssemblies()
For Each i In csxFiles
For Each i In csFiles
Try
CSScriptLibrary.CSScript.Evaluator.LoadCode(File.ReadAllText(i))
Catch ex As Exception

View File

@@ -10,7 +10,7 @@
<AssemblyName>CSScriptAddon</AssemblyName>
<FileAlignment>512</FileAlignment>
<MyType>Windows</MyType>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -55,11 +55,11 @@
<Reference Include="mpvnet, Version=0.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\mpvnet\bin\Debug\mpvnet.exe</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Data" />
<Reference Include="System.Management" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@@ -67,6 +67,7 @@
<Reference Include="System.Net.Http" />
<Reference Include="vbnet">
<HintPath>..\vbnet\bin\Debug\vbnet.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>

View File

@@ -15,7 +15,7 @@ Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0"), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase

View File

@@ -13,6 +13,14 @@ https://mpv.io/manual/master/
![](https://github.com/stax76/mpvnet/blob/master/mpvnet/screenshot.jpg)
### Context Menu
The context menu can be customized via input.conf file located at:
C:\Users\Frank\AppData\Roaming\mpv\input.conf
https://github.com/stax76/mpvnet/blob/master/mpvnet/Resources/input_conf.txt
### C# Scripting
A simple C# script located at: C:\Users\Frank\AppData\Roaming\mpv\scripts\test.cs
@@ -36,10 +44,24 @@ class Script
}
```
### Context Menu
### Changes
The context menu can be customized via input.conf file located at:
### 0.2.3
C:\Users\Frank\AppData\Roaming\mpv\input.conf
- changed minimum runtime to .NET 4.7.2
- fixed mpv.net not working with new mpv lib
- the track name in the title bar was sometimes wrong
- mpv lib updated to 2018-12-16
- quit-watch-later added to context menu (Shift+Q) to exit and resume at the last position
- ab loop added to menu
- added the possibility to modify mpv.conf settings using the context menu
- added link to the manual and default keys to the menu
https://github.com/stax76/mpvnet/blob/master/mpvnet/Resources/input_conf.txt
### 0.2.2
- history feature added
- mpv lib updated
### 0.2.1
- right-click in fullscreen in the right-left corner closes the app

View File

@@ -1,22 +1,4 @@
/**
*mpv.net
*Copyright(C) 2017 stax76
*
*This program is free software: you can redistribute it and/or modify
*it under the terms of the GNU General Public License as published by
*the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program. If not, see http://www.gnu.org/licenses/.
*/
using System;
using System;
using System.ComponentModel.Composition;
using System.Collections.Generic;

View File

@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Rating</RootNamespace>
<AssemblyName>RatingAddon</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
@@ -69,6 +69,7 @@
<ItemGroup>
<Reference Include="mpvnet">
<HintPath>..\mpvnet\bin\Debug\mpvnet.exe</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />

View File

@@ -0,0 +1,31 @@
// when seeking displays position and
// duration like so: 00:00 / 120:00
// this is different from MPC which
// uses 00:00:00 / 02:00:00
function add_zero(val)
{
val = Math.round(val);
return val > 9 ? "" + val : "0" + val;
}
function format(val)
{
var sec = Math.round(val);
if (sec < 0)
sec = 0;
pos_min_floor = Math.floor(sec / 60);
sec_rest = sec - pos_min_floor * 60;
return add_zero(pos_min_floor) + ":" + add_zero(sec_rest);
}
function on_seek(_)
{
mp.commandv("show-text",
format(mp.get_property_number("time-pos")) + " / " +
format(mp.get_property_number("duration")));
}
mp.register_event("seek", on_seek);

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
</configuration>

View File

@@ -1,28 +1,11 @@
/**
*mpv.net
*Copyright(C) 2017 stax76
*
*This program is free software: you can redistribute it and/or modify
*it under the terms of the GNU General Public License as published by
*the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program. If not, see http://www.gnu.org/licenses/.
*/
using System;
using System.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
using vbnet;
using static vbnet.UI.MainModule;
namespace mpvnet
{
@@ -83,21 +66,105 @@ namespace mpvnet
ProcessHelp.Start(OS.GetTextEditor(), '"' + mpv.InputConfPath + '"');
}
public static void show_prefs(string[] args)
private static void CreateMpvConf()
{
string filepath = Folder.AppDataRoaming + "mpv\\mpv.conf";
if (!File.Exists(filepath))
if (!File.Exists(mpv.mpvConfPath))
{
var dirPath = Folder.AppDataRoaming + "mpv\\";
if (!Directory.Exists(dirPath))
Directory.CreateDirectory(dirPath);
File.WriteAllText(filepath, "# https://mpv.io/manual/master/#configuration-files");
File.WriteAllText(mpv.mpvConfPath, "# https://mpv.io/manual/master/#configuration-files");
}
}
public static void show_prefs(string[] args)
{
CreateMpvConf();
ProcessHelp.Start(OS.GetTextEditor(), '"' + mpv.mpvConfPath + '"');
}
public static void history(string[] args)
{
var fp = Folder.AppDataRoaming + "mpv\\history.txt";
if (File.Exists(fp))
Process.Start(fp);
else
if (MsgQuestion($"Create history.txt file in config folder?{BR2}mpv.net will write the date, time and filename of opened files to it.") == DialogResult.OK)
File.WriteAllText(fp, "");
}
public static void shell_execute(string[] args)
{
Process.Start(args[0]);
}
public static void set_setting(string[] args)
{
CreateMpvConf();
bool changed = false;
string fp = mpv.mpvConfPath;
var confLines = File.ReadAllLines(fp);
for (int i = 0; i < confLines.Length; i++)
{
if (confLines[i].Left("=").Trim() == args[0])
{
confLines[i] = args[0] + "=" + args[1];
changed = true;
}
}
ProcessHelp.Start(OS.GetTextEditor(), '"' + filepath + '"');
if (changed)
{
File.WriteAllText(fp, String.Join(Environment.NewLine, confLines));
}
else
{
File.WriteAllText(fp,
File.ReadAllText(fp) + Environment.NewLine + args[0] + "=" + args[1]);
}
MsgInfo("Please restart mpv.net");
}
public static void show_info(string[] args)
{
var fi = new FileInfo(mpv.GetStringProp("path"));
using (var mi = new MediaInfo(fi.FullName))
{
var w = mi.GetInfo(StreamKind.Video, "Width");
var h = mi.GetInfo(StreamKind.Video, "Height");
var pos = TimeSpan.FromSeconds(mpv.GetIntProp("time-pos"));
var dur = TimeSpan.FromSeconds(mpv.GetIntProp("duration"));
string mibr = mi.GetInfo(StreamKind.Video, "BitRate");
if (mibr == "")
mibr = "0";
var br = Convert.ToInt32(mibr) / 1000.0 / 1000.0;
var vf = mpv.GetStringProp("video-format").ToUpper();
var fn = fi.Name;
if (fn.Length > 60)
fn = fn.Insert(59, BR);
var info =
FormatTime(pos.TotalMinutes) + ":" +
FormatTime(pos.Seconds) + " / " +
FormatTime(dur.TotalMinutes) + ":" +
FormatTime(dur.Seconds) + "\n" +
((int)(fi.Length / 1024 / 1024)).ToString() +
$" MB - {w} x {h}\n{vf} - {br.ToString("f1")} Mb/s" + "\n" + fn;
mpv.Command("show-text", info, "5000");
string FormatTime(double value) => ((int)(Math.Floor(value))).ToString("00");
}
}
}
}

View File

@@ -1,28 +1,8 @@
/**
*mpv.net
*Copyright(C) 2017 stax76
*
*This program is free software: you can redistribute it and/or modify
*it under the terms of the GNU General Public License as published by
*the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program. If not, see http://www.gnu.org/licenses/.
*/
using System;
using System.Diagnostics;
using System;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using vbnet;
@@ -48,13 +28,14 @@ namespace mpvnet
{
Application.ThreadException += Application_ThreadException;
InitializeComponent();
SetFormPosSize();
Instance = this;
Hwnd = Handle;
mpv.Init();
mpv.ObserveBoolProp("fullscreen", MpvChangeFullscreen);
mpv.AfterShutdown += Mpv_AfterShutdown;
mpv.VideoSizeChanged += Mpv_VideoSizeChanged;
mpv.PlaybackRestart += Mpv_PlaybackRestart;
mpv.PlaybackRestart += mpv_PlaybackRestart;
ToolStripManager.Renderer = new ToolStripRendererEx(ToolStripRenderModeEx.SystemDefault);
CMS = new ContextMenuStripEx(components);
@@ -101,7 +82,7 @@ namespace mpvnet
var menuItem = CMS.Add(path, () => {
try
{
mpv.CommandString(cmd);
mpv.CommandString(cmd, false);
}
catch (Exception e)
{
@@ -119,9 +100,19 @@ namespace mpvnet
CursorHelp.Show();
}
private void Mpv_PlaybackRestart()
private string LastHistory;
private void mpv_PlaybackRestart()
{
BeginInvoke(new Action(() => Text = mpv.GetStringProp("filename") + " - mpv.net " + Application.ProductVersion));
var fn = mpv.GetStringProp("filename");
BeginInvoke(new Action(() => { Text = fn + " - mpv.net " + Application.ProductVersion; }));
var fp = Folder.AppDataRoaming + "mpv\\history.txt";
if (LastHistory != fn && File.Exists(fp))
{
File.AppendAllText(fp, DateTime.Now.ToString() + " " + Path.GetFileNameWithoutExtension(fn) + BR);
LastHistory = fn;
}
}
private void CM_Popup(object sender, EventArgs e)
@@ -139,12 +130,6 @@ namespace mpvnet
MsgException(e);
}
private void About()
{
mpv.Command("show-text", Application.ProductName + " v" + Application.ProductVersion.ToString() +
"\nCopyright (c) 2017 stax76\nGPL License", "5000");
}
private void Mpv_VideoSizeChanged()
{
BeginInvoke(new Action(() => SetFormPosSize()));
@@ -267,6 +252,13 @@ namespace mpvnet
Native.ReleaseCapture();
Native.PostMessage(Handle, 0xA1 /* WM_NCLBUTTONDOWN */, HTCAPTION, IntPtr.Zero);
}
var sb = Screen.FromControl(this).Bounds;
var p1 = new Point(sb.Width, 0);
var p2 = PointToScreen(e.Location);
if (Math.Abs(p1.X - p2.X) < 10 && Math.Abs(p1.Y - p2.Y) < 10)
mpv.Command("quit");
}
protected override void OnMouseMove(MouseEventArgs e)

View File

@@ -1,22 +1,4 @@
/**
*mpv.net
*Copyright(C) 2017 stax76
*
*This program is free software: you can redistribute it and/or modify
*it under the terms of the GNU General Public License as published by
*the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program. If not, see http://www.gnu.org/licenses/.
*/
using System;
using System;
using System.Drawing;
using System.Runtime.InteropServices;

View File

@@ -1,22 +1,4 @@
/**
*mpv.net
*Copyright(C) 2017 stax76
*
*This program is free software: you can redistribute it and/or modify
*it under the terms of the GNU General Public License as published by
*the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program. If not, see http://www.gnu.org/licenses/.
*/
using System;
using System;
namespace mpvnet
{

View File

@@ -1,22 +1,4 @@
/**
*mpv.net
*Copyright(C) 2017 stax76
*
*This program is free software: you can redistribute it and/or modify
*it under the terms of the GNU General Public License as published by
*the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program. If not, see http://www.gnu.org/licenses/.
*/
using System;
using System;
using System.Windows.Forms;
namespace mpvnet

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// 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("0.2.0.0")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyVersion("0.2.3.0")]
[assembly: AssemblyFileVersion("0.2.3.0")]

View File

@@ -66,7 +66,7 @@ namespace mpvnet.Properties {
///
///o script-message mpv.net open-files #menu: O; Open Files
///
///Space pause #menu: Space ; Play/Pause
///Space cycle pause #menu: Space ; Play/Pause
///s stop #menu: S ; Stop
///
///F11 playlist-prev #menu: F11 ; Navigate | Previous

View File

@@ -12,7 +12,7 @@ namespace mpvnet.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));

View File

@@ -1,9 +1,9 @@
#key command key caption menu path/caption
o script-message mpv.net open-files #menu: O; Open Files
o script-message mpv.net open-files #menu: O; Open Files
Space pause #menu: Space ; Play/Pause
Space cycle pause #menu: Space ; Play/Pause
s stop #menu: S ; Stop
F11 playlist-prev #menu: F11 ; Navigate | Previous
@@ -20,20 +20,20 @@ KP8 cycle sub #menu: Numpad 8 ; Cycle Subtitle
- add volume -5 #menu: - ; Volume | Down
Axis_Up add volume 5 # wheel up
Axis_Down add volume -5 # wheel down
_ _ #menu: _ ; Volume | -
m mute #menu: M ; Volume | Mute
_ ignore #menu: _ ; Volume | -
m cycle mute #menu: M ; Volume | Mute
Alt++ add audio-delay 0.1 #menu: Alt++ ; Audio | Delay +0.1
Alt+- add audio-delay -0.1 #menu: Alt+- ; Audio | Delay -0.1
KP6 add audio-delay 0.100 #menu: Numpad 6 ; Audio | Delay +0.1
KP9 add audio-delay -0.100 #menu: Numpad 9 ; Audio | Delay -0.1
Right seek 10 #menu: Right ; Seek | 10 sec forward
Left seek -10 #menu: Left ; Seek | 10 sec backward
_ _ #menu: _ ; Seek | -
Up seek 60 #menu: Up ; Seek | 1 min forward
Down seek -60 #menu: Down ; Seek | 1 min backward
_ _ #menu: _ ; Seek | -
Ctrl+Right seek 300 #menu: Ctrl+Right ; Seek | 5 min forward
Ctrl+Left seek -300 #menu: Ctrl+Left ; Seek | 5 min backward
Right no-osd seek 10 #menu: Right ; Seek | 10 sec forward
Left no-osd seek -10 #menu: Left ; Seek | 10 sec backward
_ ignore #menu: _ ; Seek | -
Up no-osd seek 40 #menu: Up ; Seek | 1 min forward
Down no-osd seek -40 #menu: Down ; Seek | 1 min backward
_ ignore #menu: _ ; Seek | -
Ctrl+Right no-osd seek 300 #menu: Ctrl+Right ; Seek | 5 min forward
Ctrl+Left no-osd seek -300 #menu: Ctrl+Left ; Seek | 5 min backward
KP0 script-message rate-file 0 #menu: Numpad 0 ; Addons | Rating | 0stars
KP1 script-message rate-file 1 #menu: Numpad 1 ; Addons | Rating | 1stars
@@ -42,8 +42,17 @@ KP3 script-message rate-file 3 #menu: Numpad 3 ; Addons | Rating | 3stars
KP4 script-message rate-file 4 #menu: Numpad 4 ; Addons | Rating | 4stars
KP5 script-message rate-file 5 #menu: Numpad 5 ; Addons | Rating | 5stars
p script-message mpv.net show-prefs #menu: P ; Preferences
k script-message mpv.net show-keys #menu: K ; Keys
_ script-message mpv.net set-setting hwdec yes #menu: _ ; Settings | Hardware Decoding | Enable Hardware Decoding
_ script-message mpv.net set-setting hwdec no #menu: _ ; Settings | Hardware Decoding | Disable Hardware Decoding
F8 script-message mpv.net open-config-folder #menu: _ ; Tools | Config Folder
p script-message mpv.net show-prefs #menu: P ; Settings | Show Preferences
k script-message mpv.net show-keys #menu: K ; Settings | Show Keys
i script-message mpv.net show-info #menu: I ; Tools | Info
c script-message mpv.net open-config-folder #menu: _ ; Tools | Config Folder
h script-message mpv.net history #menu: H ; Tools | History
l ab-loop #menu: L ; Tools | AB Loop
_ script-message mpv.net shell-execute https://mpv.io/manual/stable/ #menu: _ ; Tools | mpv Manual
_ script-message mpv.net shell-execute https://github.com/mpv-player/mpv/blob/master/etc/input.conf #menu: _ ; Tools | mpv Default Keys
Esc quit #menu: Escape ; Exit
Q quit-watch-later #menu: Shift+Q; Exit Watch Later

View File

@@ -1,32 +1,6 @@
/**
*mpv.net
*Copyright(C) 2017 stax76
*
*This program is free software: you can redistribute it and/or modify
*it under the terms of the GNU General Public License as published by
*the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program. If not, see http://www.gnu.org/licenses/.
*/
using Microsoft.VisualBasic;
using System;
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
public static class StringExtensions
{

View File

@@ -1,22 +1,4 @@
/**
*mpv.net
*Copyright(C) 2017 stax76
*
*This program is free software: you can redistribute it and/or modify
*it under the terms of the GNU General Public License as published by
*the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program. If not, see http://www.gnu.org/licenses/.
*/
using System;
using System;
using System.Drawing;
using System.Windows.Forms;

View File

@@ -1,22 +1,4 @@
/**
*mpv.net
*Copyright(C) 2017 stax76
*
*This program is free software: you can redistribute it and/or modify
*it under the terms of the GNU General Public License as published by
*the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program. If not, see http://www.gnu.org/licenses/.
*/
using System;
using System;
using System.Runtime.InteropServices;
namespace mpvnet

View File

@@ -1,23 +1,4 @@
/**
*mpv.net
*Copyright(C) 2017 stax76
*
*This program is free software: you can redistribute it and/or modify
*it under the terms of the GNU General Public License as published by
*the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program. If not, see http://www.gnu.org/licenses/.
*/
using System;
using System.Diagnostics;
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
@@ -31,6 +12,7 @@ using static mpvnet.Native;
using vbnet;
using static vbnet.UI.MainModule;
using System.Diagnostics;
namespace mpvnet
{
@@ -41,7 +23,6 @@ namespace mpvnet
public static event Action<string[]> ClientMessage;
public static event Action Shutdown;
public static event Action AfterShutdown;
public static event Action FileLoaded;
public static event Action PlaybackRestart;
public static event Action VideoSizeChanged;
@@ -49,8 +30,9 @@ namespace mpvnet
public static IntPtr MpvWindowHandle;
public static Addon Addon;
public static List<Action<bool>> BoolPropChangeActions = new List<Action<bool>>();
public static Size VideoSize;
public static Size VideoSize = new Size(1920, 1080);
public static string InputConfPath = Folder.AppDataRoaming + "mpv\\input.conf";
public static string mpvConfPath = Folder.AppDataRoaming + "mpv\\mpv.conf";
public static StringPairList BindingList = new StringPairList();
public static void Init()
@@ -97,13 +79,14 @@ namespace mpvnet
AfterShutdown?.Invoke();
return;
case mpv_event_id.MPV_EVENT_FILE_LOADED:
FileLoaded?.Invoke();
LoadFolder();
break;
case mpv_event_id.MPV_EVENT_PLAYBACK_RESTART:
PlaybackRestart?.Invoke();
var s = new Size(GetIntProp("dwidth"), GetIntProp("dheight"));
if (VideoSize != s)
Size s = new Size(GetIntProp("dwidth", false), GetIntProp("dheight", false));
if (VideoSize != s && s != Size.Empty)
{
VideoSize = s;
VideoSizeChanged?.Invoke();
@@ -119,7 +102,14 @@ namespace mpvnet
if (args != null && args.Length > 1 && args[0] == "mpv.net")
foreach (var i in mpvnet.Command.Commands)
if (args[1] == i.Name)
i.Action(args.Skip(2).ToArray());
try
{
i.Action(args.Skip(2).ToArray());
}
catch (Exception ex)
{
MsgError(ex.GetType().Name, ex.ToString());
}
ClientMessage?.Invoke(args);
}
@@ -154,14 +144,14 @@ namespace mpvnet
Marshal.FreeHGlobal(mainPtr);
}
public static void CommandString(string command)
public static void CommandString(string command, bool throwException = true)
{
if (MpvHandle == IntPtr.Zero)
return;
int err = mpv_command_string(MpvHandle, command);
if (err < 0)
if (err < 0 && throwException)
throw new Exception($"{(mpv_error)err}" + BR2 + command);
}
@@ -178,21 +168,22 @@ namespace mpvnet
{
var lpBuffer = IntPtr.Zero;
int err = mpv_get_property(MpvHandle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, ref lpBuffer);
var ret = StringFromNativeUtf8(lpBuffer);
mpv_free(lpBuffer);
if (err < 0)
throw new Exception($"{name}: {(mpv_error)err}");
var ret = StringFromNativeUtf8(lpBuffer);
mpv_free(lpBuffer);
return ret;
}
public static int GetIntProp(string name)
public static int GetIntProp(string name, bool throwException = true)
{
var lpBuffer = IntPtr.Zero;
int err = mpv_get_property(MpvHandle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref lpBuffer);
if (err < 0)
if (err < 0 && throwException)
throw new Exception($"{name}: {(mpv_error)err}");
else
return lpBuffer.ToInt32();
@@ -249,8 +240,6 @@ namespace mpvnet
mpv.SetStringProp(i.Substring(2), "yes");
}
}
LoadFolder();
}
public static void LoadFiles(string[] files)
@@ -268,8 +257,13 @@ namespace mpvnet
mpv.LoadFolder();
}
private static bool WasFolderLoaded;
public static void LoadFolder()
{
if (WasFolderLoaded)
return;
if (GetIntProp("playlist-count") == 1)
{
string[] types = "264 265 3gp aac ac3 avc avi avs bmp divx dts dtshd dtshr dtsma eac3 evo flac flv h264 h265 hevc hvc jpg jpeg m2t m2ts m2v m4a m4v mka mkv mlp mov mp2 mp3 mp4 mpa mpeg mpg mpv mts ogg ogm opus pcm png pva raw rmvb thd thd+ac3 true-hd truehd ts vdr vob vpy w64 wav webm wmv y4m".Split(' ');
@@ -286,6 +280,8 @@ namespace mpvnet
if (index > 0)
Command("playlist-move", "0", (index + 1).ToString());
}
WasFolderLoaded = true;
}
public static IntPtr AllocateUtf8IntPtrArrayWithSentinel(string[] arr, out IntPtr[] byteArrayPointers)

View File

@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>mpvnet</RootNamespace>
<AssemblyName>mpvnet</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />

8
release_mpvnet.ps1 Normal file
View File

@@ -0,0 +1,8 @@
using namespace System.Diagnostics
$exePath = "C:\Users\frank\Desktop\Projekte\mpvnet\mpvnet\bin\Debug\mpvnet.exe"
$version = [FileVersionInfo]::GetVersionInfo($exePath).FileVersion
$targetDir = "C:\Users\Frank\Desktop\mpv-net-" + $version
Copy-Item C:\Users\frank\Desktop\Projekte\mpvnet\mpvnet\bin\Debug $targetDir -recurse
$addonDir = $targetDir + "\Addons"
remove-item $addonDir -Recurse -Include *vbnet.pdb, *mpvnet.exe, *mpvnet.exe.config, *mpvnet.pdb, *vbnet.dll
D:\Projekte\VS\VB\util\bin\util.exe -pack $targetDir

93
vbnet/MediaInfo.vb Normal file
View File

@@ -0,0 +1,93 @@
Imports System.Runtime.InteropServices
Public Class MediaInfo
Implements IDisposable
Private Handle As IntPtr
Shared Loaded As Boolean
Sub New(sourcepath As String)
If Not Loaded Then
If LoadLibrary("MediaInfo.dll") = IntPtr.Zero Then Throw New Exception("Failed to load MediaInfo.dll.")
Loaded = True
End If
Handle = MediaInfo_New()
MediaInfo_Open(Handle, sourcepath)
End Sub
Public Function GetInfo(streamKind As StreamKind, parameter As String) As String
Return Marshal.PtrToStringUni(MediaInfo_Get(Handle, streamKind, 0, parameter, InfoKind.Text, InfoKind.Name))
End Function
#Region "IDisposable"
Private Disposed As Boolean
Sub Dispose() Implements IDisposable.Dispose
If Not Disposed Then
Disposed = True
MediaInfo_Close(Handle)
MediaInfo_Delete(Handle)
End If
End Sub
Protected Overrides Sub Finalize()
Dispose()
End Sub
#End Region
#Region "native"
<DllImport("kernel32.dll", CharSet:=CharSet.Unicode)>
Private Shared Function LoadLibrary(path As String) As IntPtr
End Function
<DllImport("MediaInfo.dll")>
Private Shared Function MediaInfo_New() As IntPtr
End Function
<DllImport("MediaInfo.dll")>
Private Shared Sub MediaInfo_Delete(Handle As IntPtr)
End Sub
<DllImport("MediaInfo.dll", CharSet:=CharSet.Unicode)>
Private Shared Function MediaInfo_Open(Handle As IntPtr, FileName As String) As Integer
End Function
<DllImport("MediaInfo.dll")>
Private Shared Function MediaInfo_Close(Handle As IntPtr) As Integer
End Function
<DllImport("MediaInfo.dll", CharSet:=CharSet.Unicode)>
Private Shared Function MediaInfo_Get(Handle As IntPtr,
StreamKind As StreamKind,
StreamNumber As Integer, Parameter As String,
KindOfInfo As InfoKind,
KindOfSearch As InfoKind) As IntPtr
End Function
#End Region
End Class
Public Enum StreamKind
General
Video
Audio
Text
Chapters
Image
End Enum
Public Enum InfoKind
Name
Text
Measure
Options
NameText
MeasureText
Info
HowTo
End Enum

View File

@@ -15,7 +15,7 @@ Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0"), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase

View File

@@ -10,7 +10,7 @@
<AssemblyName>vbnet</AssemblyName>
<FileAlignment>512</FileAlignment>
<MyType>Windows</MyType>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -75,6 +75,7 @@
<Compile Include="Extensions.vb" />
<Compile Include="HSLColor.vb" />
<Compile Include="MainModule.vb" />
<Compile Include="MediaInfo.vb" />
<Compile Include="Menu.vb">
<SubType>Component</SubType>
</Compile>