-
This commit is contained in:
@@ -11,7 +11,7 @@ Public Class CSScriptAddon
|
|||||||
Implements IAddon
|
Implements IAddon
|
||||||
|
|
||||||
Sub New()
|
Sub New()
|
||||||
Dim scriptDir = mp.mpvConfFolderPath + "scripts"
|
Dim scriptDir = mp.MpvConfFolderPath + "scripts"
|
||||||
If Not Directory.Exists(scriptDir) Then Return
|
If Not Directory.Exists(scriptDir) Then Return
|
||||||
Dim csFiles = Directory.GetFiles(scriptDir, "*.cs").ToList
|
Dim csFiles = Directory.GetFiles(scriptDir, "*.cs").ToList
|
||||||
csFiles.AddRange(Directory.GetFiles(Application.StartupPath + "\\Scripts", "*.cs"))
|
csFiles.AddRange(Directory.GetFiles(Application.StartupPath + "\\Scripts", "*.cs"))
|
||||||
|
|||||||
12
README.md
12
README.md
@@ -23,7 +23,7 @@ Table of contents
|
|||||||
- Searchable options dialog with modern UI as mpv compatible standalone application
|
- Searchable options dialog with modern UI as mpv compatible standalone application
|
||||||
- Searchable input (key/mouse) binding editor with modern UI as mpv compatible standalone application
|
- Searchable input (key/mouse) binding editor with modern UI as mpv compatible standalone application
|
||||||
- Modern UI using the OS theme color and dark mode
|
- Modern UI using the OS theme color and dark mode
|
||||||
- Rich addon API for .NET languages, over 700 available mpv properties
|
- Rich addon/extension API for .NET languages, over 700 available mpv properties
|
||||||
- Rich scripting API for Python, C#, Lua, JavaScript and PowerShell
|
- Rich scripting API for Python, C#, Lua, JavaScript and PowerShell
|
||||||
- mpv's OSC (on screen controller (play control bar)), IPC, conf files
|
- mpv's OSC (on screen controller (play control bar)), IPC, conf files
|
||||||
|
|
||||||
@@ -73,6 +73,14 @@ https://github.com/stax76/mpv.net/wiki/Scripting-(CSharp,-Python,-JavaScript,-Lu
|
|||||||
|
|
||||||
### Changelog
|
### Changelog
|
||||||
|
|
||||||
|
### 3.0 (20??-??-??)
|
||||||
|
|
||||||
|
- the history feature logs only files that were opened longer than 90 seconds
|
||||||
|
- the default input command for cycling the audio tracks was replaced with an
|
||||||
|
mpv.net command that shows detailed track info and has no 'no audio' track
|
||||||
|
|
||||||
|
[go to download page](https://github.com/stax76/mpv.net/releases)
|
||||||
|
|
||||||
### 2.9 (2019-04-16)
|
### 2.9 (2019-04-16)
|
||||||
|
|
||||||
- clicking the right top corner in full screen mode
|
- clicking the right top corner in full screen mode
|
||||||
@@ -97,5 +105,3 @@ https://github.com/stax76/mpv.net/wiki/Scripting-(CSharp,-Python,-JavaScript,-Lu
|
|||||||
can be seen and selected, it shows video, audio and subtitle
|
can be seen and selected, it shows video, audio and subtitle
|
||||||
tracks with various metadata. [Menu default definition](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt#L104).
|
tracks with various metadata. [Menu default definition](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt#L104).
|
||||||
The screenshots were updated showing the [new track menu](https://github.com/stax76/mpv.net#screenshots).
|
The screenshots were updated showing the [new track menu](https://github.com/stax76/mpv.net#screenshots).
|
||||||
|
|
||||||
[go to download page](https://github.com/stax76/mpv.net/releases)
|
|
||||||
@@ -10,7 +10,7 @@ namespace RatingAddon
|
|||||||
[Export(typeof(IAddon))]
|
[Export(typeof(IAddon))]
|
||||||
public class RatingAddon : IAddon
|
public class RatingAddon : IAddon
|
||||||
{
|
{
|
||||||
private Dictionary<string, int> Dic = new Dictionary<string, int>();
|
Dictionary<string, int> Dic = new Dictionary<string, int>();
|
||||||
|
|
||||||
public RatingAddon()
|
public RatingAddon()
|
||||||
{
|
{
|
||||||
@@ -18,7 +18,7 @@ namespace RatingAddon
|
|||||||
mp.Shutdown += mpv_Shutdown;
|
mp.Shutdown += mpv_Shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mpv_Shutdown()
|
void mpv_Shutdown()
|
||||||
{
|
{
|
||||||
foreach (var i in Dic)
|
foreach (var i in Dic)
|
||||||
{
|
{
|
||||||
@@ -44,7 +44,7 @@ namespace RatingAddon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mpv_ClientMessage(string[] args)
|
void mpv_ClientMessage(string[] args)
|
||||||
{
|
{
|
||||||
int rating;
|
int rating;
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ Public Class Msg
|
|||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Shared ShownMessages As String
|
Shared ShownMessages As String
|
||||||
|
|
||||||
Public Shared Sub ShowWarning(mainInstruction As String,
|
Public Shared Sub ShowWarning(mainInstruction As String,
|
||||||
Optional content As String = Nothing,
|
Optional content As String = Nothing,
|
||||||
@@ -421,11 +421,11 @@ Public Class TaskDialog(Of T)
|
|||||||
|
|
||||||
Private ExitTickCount As Integer
|
Private ExitTickCount As Integer
|
||||||
|
|
||||||
Private Function DialogProc(hwnd As IntPtr,
|
Function DialogProc(hwnd As IntPtr,
|
||||||
msg As UInteger,
|
msg As UInteger,
|
||||||
wParam As IntPtr,
|
wParam As IntPtr,
|
||||||
lParam As IntPtr,
|
lParam As IntPtr,
|
||||||
lpRefData As IntPtr) As Integer
|
lpRefData As IntPtr) As Integer
|
||||||
Select Case msg
|
Select Case msg
|
||||||
Case TDN_BUTTON_CLICKED, TDN_RADIO_BUTTON_CLICKED
|
Case TDN_BUTTON_CLICKED, TDN_RADIO_BUTTON_CLICKED
|
||||||
If TypeOf SelectedValue Is MsgResult Then
|
If TypeOf SelectedValue Is MsgResult Then
|
||||||
@@ -464,7 +464,7 @@ Public Class TaskDialog(Of T)
|
|||||||
End Select
|
End Select
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Sub MarshalDialogControlStructs()
|
Sub MarshalDialogControlStructs()
|
||||||
If Not Buttons Is Nothing AndAlso Buttons.Count > 0 Then
|
If Not Buttons Is Nothing AndAlso Buttons.Count > 0 Then
|
||||||
ButtonArray = AllocateAndMarshalButtons(Buttons)
|
ButtonArray = AllocateAndMarshalButtons(Buttons)
|
||||||
Config.pButtons = ButtonArray
|
Config.pButtons = ButtonArray
|
||||||
@@ -478,7 +478,7 @@ Public Class TaskDialog(Of T)
|
|||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Shared Function AllocateAndMarshalButtons(structs As List(Of TASKDIALOG_BUTTON)) As IntPtr
|
Shared Function AllocateAndMarshalButtons(structs As List(Of TASKDIALOG_BUTTON)) As IntPtr
|
||||||
Dim initialPtr = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(TASKDIALOG_BUTTON)) * structs.Count)
|
Dim initialPtr = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(TASKDIALOG_BUTTON)) * structs.Count)
|
||||||
Dim currentPtr = initialPtr
|
Dim currentPtr = initialPtr
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace mpvnet
|
|||||||
[ImportMany]
|
[ImportMany]
|
||||||
public IEnumerable<IAddon> Addons = null;
|
public IEnumerable<IAddon> Addons = null;
|
||||||
|
|
||||||
private readonly CompositionContainer CompositionContainer;
|
readonly CompositionContainer CompositionContainer;
|
||||||
|
|
||||||
public Addon()
|
public Addon()
|
||||||
{
|
{
|
||||||
@@ -28,7 +28,7 @@ namespace mpvnet
|
|||||||
foreach (string i in Directory.GetDirectories(dir))
|
foreach (string i in Directory.GetDirectories(dir))
|
||||||
catalog.Catalogs.Add(new DirectoryCatalog(i, "*Addon.dll"));
|
catalog.Catalogs.Add(new DirectoryCatalog(i, "*Addon.dll"));
|
||||||
|
|
||||||
dir = mp.mpvConfFolderPath + "\\Addons";
|
dir = mp.MpvConfFolderPath + "\\Addons";
|
||||||
|
|
||||||
if (Directory.Exists(dir))
|
if (Directory.Exists(dir))
|
||||||
foreach (string i in Directory.GetDirectories(dir))
|
foreach (string i in Directory.GetDirectories(dir))
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using VBNET;
|
using VBNET;
|
||||||
@@ -15,7 +15,7 @@ namespace mpvnet
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public Action<string[]> Action { get; set; }
|
public Action<string[]> Action { get; set; }
|
||||||
|
|
||||||
private static List<Command> commands;
|
static List<Command> commands;
|
||||||
|
|
||||||
public static List<Command> Commands
|
public static List<Command> Commands
|
||||||
{
|
{
|
||||||
@@ -58,7 +58,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static void open_conf_folder(string[] args)
|
public static void open_conf_folder(string[] args)
|
||||||
{
|
{
|
||||||
Process.Start(mp.mpvConfFolderPath);
|
Process.Start(mp.MpvConfFolderPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void show_input_editor(string[] args)
|
public static void show_input_editor(string[] args)
|
||||||
@@ -73,7 +73,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static void show_history(string[] args)
|
public static void show_history(string[] args)
|
||||||
{
|
{
|
||||||
var fp = mp.mpvConfFolderPath + "history.txt";
|
var fp = mp.MpvConfFolderPath + "history.txt";
|
||||||
|
|
||||||
if (File.Exists(fp))
|
if (File.Exists(fp))
|
||||||
Process.Start(fp);
|
Process.Start(fp);
|
||||||
@@ -197,5 +197,22 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void cycle_audio(string[] args)
|
||||||
|
{
|
||||||
|
string filePath = mp.get_property_string("path", false);
|
||||||
|
if (!File.Exists(filePath)) return;
|
||||||
|
|
||||||
|
using (MediaInfo mi = new MediaInfo(filePath))
|
||||||
|
{
|
||||||
|
MediaTrack[] audTracks = mp.MediaTracks.Where(track => track.Type == "a").ToArray();
|
||||||
|
if (audTracks.Length < 2) return;
|
||||||
|
int aid = mp.get_property_int("aid");
|
||||||
|
aid += 1;
|
||||||
|
if (aid > audTracks.Length) aid = 1;
|
||||||
|
mp.commandv("set", "aid", aid.ToString());
|
||||||
|
mp.commandv("show-text", audTracks[aid - 1].Text.Substring(3), "5000");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,22 +16,21 @@ namespace mpvnet
|
|||||||
public partial class MainForm : Form
|
public partial class MainForm : Form
|
||||||
{
|
{
|
||||||
public static MainForm Instance { get; set; }
|
public static MainForm Instance { get; set; }
|
||||||
public static IntPtr Hwnd;
|
public static IntPtr Hwnd { get; set; }
|
||||||
|
|
||||||
private Point LastCursorPosChanged;
|
|
||||||
private int LastCursorChangedTickCount;
|
|
||||||
private bool IgnoreDpiChanged = true;
|
|
||||||
private MenuItemEx TracksMenu;
|
|
||||||
private List<MediaTrack> MediaTracks = new List<MediaTrack>();
|
|
||||||
public new ContextMenuStripEx ContextMenu;
|
public new ContextMenuStripEx ContextMenu;
|
||||||
|
MenuItemEx TracksMenu;
|
||||||
|
|
||||||
private float MpvAutofit = 0.50f;
|
Point LastCursorPosChanged;
|
||||||
private bool MpvFullscreen;
|
int LastCursorChangedTickCount;
|
||||||
private int MpvScreen = -1;
|
bool IgnoreDpiChanged = true;
|
||||||
private string MpvNetDarkMode = "system";
|
float MpvAutofit = 0.50f;
|
||||||
private string MpvSid = "";
|
bool MpvFullscreen;
|
||||||
private string MpvAid = "";
|
int MpvScreen = -1;
|
||||||
private string MpvVid = "";
|
string MpvNetDarkMode = "system";
|
||||||
|
string MpvSid = "";
|
||||||
|
string MpvAid = "";
|
||||||
|
string MpvVid = "";
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
@@ -67,15 +66,15 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ContextMenu_Opening(object sender, CancelEventArgs e)
|
void ContextMenu_Opening(object sender, CancelEventArgs e)
|
||||||
{
|
{
|
||||||
lock (MediaTracks)
|
lock (mp.MediaTracks)
|
||||||
{
|
{
|
||||||
TracksMenu.DropDownItems.Clear();
|
TracksMenu.DropDownItems.Clear();
|
||||||
|
|
||||||
MediaTrack[] audTracks = MediaTracks.Where(track => track.Type == "a").ToArray();
|
MediaTrack[] audTracks = mp.MediaTracks.Where(track => track.Type == "a").ToArray();
|
||||||
MediaTrack[] subTracks = MediaTracks.Where(track => track.Type == "s").ToArray();
|
MediaTrack[] subTracks = mp.MediaTracks.Where(track => track.Type == "s").ToArray();
|
||||||
MediaTrack[] vidTracks = MediaTracks.Where(track => track.Type == "v").ToArray();
|
MediaTrack[] vidTracks = mp.MediaTracks.Where(track => track.Type == "v").ToArray();
|
||||||
|
|
||||||
foreach (MediaTrack track in vidTracks)
|
foreach (MediaTrack track in vidTracks)
|
||||||
{
|
{
|
||||||
@@ -284,127 +283,30 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ContextMenu_Opened(object sender, EventArgs e) => CursorHelp.Show();
|
void ContextMenu_Opened(object sender, EventArgs e) => CursorHelp.Show();
|
||||||
|
|
||||||
private string LastHistory;
|
void mp_PlaybackRestart() => BeginInvoke(new Action(() => { Text = Path.GetFileName(mp.get_property_string("path")) + " - mpv.net " + Application.ProductVersion; }));
|
||||||
|
|
||||||
private void mp_PlaybackRestart()
|
void Mp_Idle() => BeginInvoke(new Action(() => { Text = "mpv.net " + Application.ProductVersion; }));
|
||||||
{
|
|
||||||
string filePath = mp.get_property_string("path");
|
|
||||||
BeginInvoke(new Action(() => { Text = Path.GetFileName(filePath) + " - mpv.net " + Application.ProductVersion; }));
|
|
||||||
|
|
||||||
Task.Run(new Action(() => {
|
void CM_Popup(object sender, EventArgs e) => CursorHelp.Show();
|
||||||
string historyFilepath = mp.mpvConfFolderPath + "history.txt";
|
|
||||||
|
|
||||||
if (LastHistory != filePath && File.Exists(historyFilepath))
|
void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
|
||||||
{
|
|
||||||
File.AppendAllText(historyFilepath, DateTime.Now.ToString() + " " +
|
|
||||||
Path.GetFileNameWithoutExtension(filePath) + "\r\n");
|
|
||||||
LastHistory = filePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (MediaTracks)
|
|
||||||
{
|
|
||||||
MediaTracks.Clear();
|
|
||||||
|
|
||||||
using (MediaInfo mi = new MediaInfo(filePath))
|
|
||||||
{
|
|
||||||
int count = mi.GetCount(MediaInfoStreamKind.Video);
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
MediaTrack track = new MediaTrack();
|
|
||||||
Add(track, mi.GetVideo(i, "Format"));
|
|
||||||
Add(track, mi.GetVideo(i, "Format_Profile"));
|
|
||||||
Add(track, mi.GetVideo(i, "Width") + "x" + mi.GetVideo(i, "Height"));
|
|
||||||
Add(track, mi.GetVideo(i, "FrameRate") + " FPS");
|
|
||||||
Add(track, mi.GetVideo(i, "Language/String"));
|
|
||||||
Add(track, mi.GetVideo(i, "Forced") == "Yes" ? "Forced" : "");
|
|
||||||
Add(track, mi.GetVideo(i, "Default") == "Yes" ? "Default" : "");
|
|
||||||
Add(track, mi.GetVideo(i, "Title"));
|
|
||||||
track.Text = "V: " + track.Text.Trim(" ,".ToCharArray());
|
|
||||||
track.Type = "v";
|
|
||||||
track.ID = i + 1;
|
|
||||||
MediaTracks.Add(track);
|
|
||||||
}
|
|
||||||
|
|
||||||
count = mi.GetCount(MediaInfoStreamKind.Audio);
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
MediaTrack track = new MediaTrack();
|
|
||||||
Add(track, mi.GetAudio(i, "Language/String"));
|
|
||||||
Add(track, mi.GetAudio(i, "Format"));
|
|
||||||
Add(track, mi.GetAudio(i, "Format_Profile"));
|
|
||||||
Add(track, mi.GetAudio(i, "BitRate/String"));
|
|
||||||
Add(track, mi.GetAudio(i, "Channel(s)/String"));
|
|
||||||
Add(track, mi.GetAudio(i, "SamplingRate/String"));
|
|
||||||
Add(track, mi.GetAudio(i, "Forced") == "Yes" ? "Forced" : "");
|
|
||||||
Add(track, mi.GetAudio(i, "Default") == "Yes" ? "Default" : "");
|
|
||||||
Add(track, mi.GetAudio(i, "Title"));
|
|
||||||
track.Text = "A: " + track.Text.Trim(" ,".ToCharArray());
|
|
||||||
track.Type = "a";
|
|
||||||
track.ID = i + 1;
|
|
||||||
MediaTracks.Add(track);
|
|
||||||
}
|
|
||||||
|
|
||||||
count = mi.GetCount(MediaInfoStreamKind.Text);
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
MediaTrack track = new MediaTrack();
|
|
||||||
Add(track, mi.GetText(i, "Language/String"));
|
|
||||||
Add(track, mi.GetText(i, "Format"));
|
|
||||||
Add(track, mi.GetText(i, "Format_Profile"));
|
|
||||||
Add(track, mi.GetText(i, "Forced") == "Yes" ? "Forced" : "");
|
|
||||||
Add(track, mi.GetText(i, "Default") == "Yes" ? "Default" : "");
|
|
||||||
Add(track, mi.GetText(i, "Title"));
|
|
||||||
track.Text = "S: " + track.Text.Trim(" ,".ToCharArray());
|
|
||||||
track.Type = "s";
|
|
||||||
track.ID = i + 1;
|
|
||||||
MediaTracks.Add(track);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Add(MediaTrack track, string val)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(val) && !(track.Text != null && track.Text.Contains(val)))
|
|
||||||
track.Text += " " + val + ",";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
class MediaTrack
|
|
||||||
{
|
|
||||||
public string Text { get; set; }
|
|
||||||
public string Type { get; set; }
|
|
||||||
public int ID { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Mp_Idle()
|
|
||||||
{
|
|
||||||
BeginInvoke(new Action(() => { Text = "mpv.net " + Application.ProductVersion; }));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CM_Popup(object sender, EventArgs e) => CursorHelp.Show();
|
|
||||||
|
|
||||||
private void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
|
|
||||||
{
|
{
|
||||||
Msg.ShowException(e.Exception);
|
Msg.ShowException(e.Exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
Msg.ShowError(e.ExceptionObject.ToString());
|
Msg.ShowError(e.ExceptionObject.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mp_VideoSizeChanged()
|
void mp_VideoSizeChanged()
|
||||||
{
|
{
|
||||||
BeginInvoke(new Action(() => SetFormPositionAndSizeKeepHeight()));
|
BeginInvoke(new Action(() => SetFormPositionAndSizeKeepHeight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mp_Shutdown()
|
void mp_Shutdown()
|
||||||
{
|
{
|
||||||
BeginInvoke(new Action(() => Close()));
|
BeginInvoke(new Action(() => Close()));
|
||||||
}
|
}
|
||||||
@@ -531,12 +433,9 @@ namespace mpvnet
|
|||||||
CursorHelp.Show();
|
CursorHelp.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsMouseInOSC()
|
bool IsMouseInOSC() => PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9;
|
||||||
{
|
|
||||||
return PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Timer_Tick(object sender, EventArgs e)
|
void Timer_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
|
if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
|
||||||
{
|
{
|
||||||
@@ -615,14 +514,14 @@ namespace mpvnet
|
|||||||
CheckYouTube();
|
CheckYouTube();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string LastURL;
|
|
||||||
|
|
||||||
void CheckYouTube()
|
void CheckYouTube()
|
||||||
{
|
{
|
||||||
string clipboard = Clipboard.GetText();
|
string clipboard = Clipboard.GetText();
|
||||||
if (clipboard.StartsWith("https://www.youtube.com/watch?") && LastURL != clipboard && Visible)
|
|
||||||
|
if (clipboard.StartsWith("https://www.youtube.com/watch?") && RegistryHelp.GetValue("HKCU\\Software\\" + Application.ProductName, "LastYouTubeURL") != clipboard && Visible)
|
||||||
{
|
{
|
||||||
LastURL = clipboard;
|
RegistryHelp.SetValue("HKCU\\Software\\" + Application.ProductName, "LastYouTubeURL", clipboard);
|
||||||
|
|
||||||
if (Msg.ShowQuestion("Play YouTube URL?") == MsgResult.OK)
|
if (Msg.ShowQuestion("Play YouTube URL?") == MsgResult.OK)
|
||||||
mp.LoadURL(clipboard);
|
mp.LoadURL(clipboard);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ using System.Runtime.InteropServices;
|
|||||||
|
|
||||||
public class MediaInfo : IDisposable
|
public class MediaInfo : IDisposable
|
||||||
{
|
{
|
||||||
private IntPtr Handle;
|
IntPtr Handle;
|
||||||
private static bool Loaded;
|
static bool Loaded;
|
||||||
|
|
||||||
public MediaInfo(string sourcepath)
|
public MediaInfo(string sourcepath)
|
||||||
{
|
{
|
||||||
@@ -42,7 +42,7 @@ public class MediaInfo : IDisposable
|
|||||||
return Marshal.PtrToStringUni(MediaInfo_Get(Handle, MediaInfoStreamKind.Text, streamNumber, parameter, MediaInfoInfoKind.Text, MediaInfoInfoKind.Name));
|
return Marshal.PtrToStringUni(MediaInfo_Get(Handle, MediaInfoStreamKind.Text, streamNumber, parameter, MediaInfoInfoKind.Text, MediaInfoInfoKind.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Disposed;
|
bool Disposed;
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
@@ -57,32 +57,32 @@ public class MediaInfo : IDisposable
|
|||||||
~MediaInfo() { Dispose(); }
|
~MediaInfo() { Dispose(); }
|
||||||
|
|
||||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
||||||
private static extern IntPtr LoadLibrary(string path);
|
static extern IntPtr LoadLibrary(string path);
|
||||||
|
|
||||||
[DllImport("MediaInfo.dll")]
|
[DllImport("MediaInfo.dll")]
|
||||||
private static extern IntPtr MediaInfo_New();
|
static extern IntPtr MediaInfo_New();
|
||||||
|
|
||||||
[DllImport("MediaInfo.dll")]
|
[DllImport("MediaInfo.dll")]
|
||||||
private static extern void MediaInfo_Delete(IntPtr handle);
|
static extern void MediaInfo_Delete(IntPtr handle);
|
||||||
|
|
||||||
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
||||||
private static extern int MediaInfo_Open(IntPtr handle, string fileName);
|
static extern int MediaInfo_Open(IntPtr handle, string fileName);
|
||||||
|
|
||||||
[DllImport("MediaInfo.dll")]
|
[DllImport("MediaInfo.dll")]
|
||||||
private static extern int MediaInfo_Close(IntPtr handle);
|
static extern int MediaInfo_Close(IntPtr handle);
|
||||||
|
|
||||||
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
||||||
private static extern IntPtr MediaInfo_Get(IntPtr handle,
|
static extern IntPtr MediaInfo_Get(IntPtr handle,
|
||||||
MediaInfoStreamKind streamKind,
|
MediaInfoStreamKind streamKind,
|
||||||
int streamNumber,
|
int streamNumber,
|
||||||
string parameter,
|
string parameter,
|
||||||
MediaInfoInfoKind kindOfInfo,
|
MediaInfoInfoKind kindOfInfo,
|
||||||
MediaInfoInfoKind kindOfSearch);
|
MediaInfoInfoKind kindOfSearch);
|
||||||
|
|
||||||
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
||||||
private static extern int MediaInfo_Count_Get(IntPtr handle,
|
static extern int MediaInfo_Count_Get(IntPtr handle,
|
||||||
MediaInfoStreamKind streamKind,
|
MediaInfoStreamKind streamKind,
|
||||||
int streamNumber);
|
int streamNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MediaInfoStreamKind
|
public enum MediaInfoStreamKind
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
|
|||||||
public static Color ColorToolStrip3 { get; set; }
|
public static Color ColorToolStrip3 { get; set; }
|
||||||
public static Color ColorToolStrip4 { get; set; }
|
public static Color ColorToolStrip4 { get; set; }
|
||||||
|
|
||||||
private int TextOffset;
|
int TextOffset;
|
||||||
|
|
||||||
public ToolStripRendererEx()
|
public ToolStripRendererEx()
|
||||||
{
|
{
|
||||||
@@ -321,28 +321,28 @@ public struct HSLColor
|
|||||||
Luminosity = l;
|
Luminosity = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double hue;
|
double _Hue;
|
||||||
|
|
||||||
public int Hue {
|
public int Hue {
|
||||||
get => System.Convert.ToInt32(hue * 240);
|
get => System.Convert.ToInt32(_Hue * 240);
|
||||||
set => hue = CheckRange(value / 240.0);
|
set => _Hue = CheckRange(value / 240.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double saturation;
|
double _Saturation;
|
||||||
|
|
||||||
public int Saturation {
|
public int Saturation {
|
||||||
get => System.Convert.ToInt32(saturation * 240);
|
get => System.Convert.ToInt32(_Saturation * 240);
|
||||||
set => saturation = CheckRange(value / 240.0);
|
set => _Saturation = CheckRange(value / 240.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double luminosity;
|
double _Luminosity;
|
||||||
|
|
||||||
public int Luminosity {
|
public int Luminosity {
|
||||||
get => System.Convert.ToInt32(luminosity * 240);
|
get => System.Convert.ToInt32(_Luminosity * 240);
|
||||||
set => luminosity = CheckRange(value / 240.0);
|
set => _Luminosity = CheckRange(value / 240.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double CheckRange(double value)
|
double CheckRange(double value)
|
||||||
{
|
{
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
value = 0;
|
value = 0;
|
||||||
@@ -367,21 +367,21 @@ public struct HSLColor
|
|||||||
{
|
{
|
||||||
double r = 0, g = 0, b = 0;
|
double r = 0, g = 0, b = 0;
|
||||||
|
|
||||||
if (luminosity != 0)
|
if (_Luminosity != 0)
|
||||||
{
|
{
|
||||||
if (saturation == 0)
|
if (_Saturation == 0)
|
||||||
{
|
{
|
||||||
b = luminosity;
|
b = _Luminosity;
|
||||||
g = luminosity;
|
g = _Luminosity;
|
||||||
r = luminosity;
|
r = _Luminosity;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double temp2 = GetTemp2(this);
|
double temp2 = GetTemp2(this);
|
||||||
double temp1 = 2.0 * luminosity - temp2;
|
double temp1 = 2.0 * _Luminosity - temp2;
|
||||||
r = GetColorComponent(temp1, temp2, hue + 1.0 / 3.0);
|
r = GetColorComponent(temp1, temp2, _Hue + 1.0 / 3.0);
|
||||||
g = GetColorComponent(temp1, temp2, hue);
|
g = GetColorComponent(temp1, temp2, _Hue);
|
||||||
b = GetColorComponent(temp1, temp2, hue - 1.0 / 3.0);
|
b = GetColorComponent(temp1, temp2, _Hue - 1.0 / 3.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@ public struct HSLColor
|
|||||||
System.Convert.ToInt32(255 * b));
|
System.Convert.ToInt32(255 * b));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double GetColorComponent(double temp1, double temp2, double temp3)
|
static double GetColorComponent(double temp1, double temp2, double temp3)
|
||||||
{
|
{
|
||||||
temp3 = MoveIntoRange(temp3);
|
temp3 = MoveIntoRange(temp3);
|
||||||
|
|
||||||
@@ -405,7 +405,7 @@ public struct HSLColor
|
|||||||
return temp1;
|
return temp1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double MoveIntoRange(double temp3)
|
static double MoveIntoRange(double temp3)
|
||||||
{
|
{
|
||||||
if (temp3 < 0)
|
if (temp3 < 0)
|
||||||
temp3 += 1;
|
temp3 += 1;
|
||||||
@@ -414,14 +414,14 @@ public struct HSLColor
|
|||||||
return temp3;
|
return temp3;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double GetTemp2(HSLColor hslColor)
|
static double GetTemp2(HSLColor hslColor)
|
||||||
{
|
{
|
||||||
double temp2;
|
double temp2;
|
||||||
|
|
||||||
if (hslColor.luminosity < 0.5)
|
if (hslColor._Luminosity < 0.5)
|
||||||
temp2 = hslColor.luminosity * (1.0 + hslColor.saturation);
|
temp2 = hslColor._Luminosity * (1.0 + hslColor._Saturation);
|
||||||
else
|
else
|
||||||
temp2 = hslColor.luminosity + hslColor.saturation - (hslColor.luminosity * hslColor.saturation);
|
temp2 = hslColor._Luminosity + hslColor._Saturation - (hslColor._Luminosity * hslColor._Saturation);
|
||||||
|
|
||||||
return temp2;
|
return temp2;
|
||||||
}
|
}
|
||||||
@@ -429,17 +429,17 @@ public struct HSLColor
|
|||||||
public static HSLColor Convert(Color c)
|
public static HSLColor Convert(Color c)
|
||||||
{
|
{
|
||||||
HSLColor r = new HSLColor();
|
HSLColor r = new HSLColor();
|
||||||
r.hue = c.GetHue() / 360.0;
|
r._Hue = c.GetHue() / 360.0;
|
||||||
r.luminosity = c.GetBrightness();
|
r._Luminosity = c.GetBrightness();
|
||||||
r.saturation = c.GetSaturation();
|
r._Saturation = c.GetSaturation();
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRGB(int red, int green, int blue)
|
public void SetRGB(int red, int green, int blue)
|
||||||
{
|
{
|
||||||
HSLColor hc = HSLColor.Convert(Color.FromArgb(red, green, blue));
|
HSLColor hc = HSLColor.Convert(Color.FromArgb(red, green, blue));
|
||||||
hue = hc.hue;
|
_Hue = hc._Hue;
|
||||||
saturation = hc.saturation;
|
_Saturation = hc._Saturation;
|
||||||
luminosity = hc.luminosity;
|
_Luminosity = hc._Luminosity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,6 +99,15 @@ namespace mpvnet
|
|||||||
rk.SetValue(name, value);
|
rk.SetValue(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetValue(string path, string name)
|
||||||
|
{
|
||||||
|
using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5)))
|
||||||
|
if (rk != null)
|
||||||
|
return rk.GetValue(name, "").ToString();
|
||||||
|
else
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
public static void RemoveKey(string path)
|
public static void RemoveKey(string path)
|
||||||
{
|
{
|
||||||
GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false);
|
GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false);
|
||||||
@@ -122,4 +131,11 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class MediaTrack
|
||||||
|
{
|
||||||
|
public string Text { get; set; }
|
||||||
|
public string Type { get; set; }
|
||||||
|
public int ID { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
d cycle deinterlace #menu: Video > Toggle Deinterlace
|
d cycle deinterlace #menu: Video > Toggle Deinterlace
|
||||||
a cycle-values video-aspect "16:9" "4:3" "2.35:1" "-1" #menu: Video > Cycle Aspect Ratio
|
a cycle-values video-aspect "16:9" "4:3" "2.35:1" "-1" #menu: Video > Cycle Aspect Ratio
|
||||||
|
|
||||||
KP7 cycle audio #menu: Audio > Cycle/Next
|
KP7 script-message mpv.net cycle-audio #menu: Audio > Cycle/Next
|
||||||
_ ignore #menu: Audio > -
|
_ ignore #menu: Audio > -
|
||||||
KP6 add audio-delay 0.100 #menu: Audio > Delay +0.1
|
KP6 add audio-delay 0.100 #menu: Audio > Delay +0.1
|
||||||
KP9 add audio-delay -0.100 #menu: Audio > Delay -0.1
|
KP9 add audio-delay -0.100 #menu: Audio > Delay -0.1
|
||||||
@@ -116,12 +116,12 @@
|
|||||||
_ ignore #menu: Speed > -
|
_ ignore #menu: Speed > -
|
||||||
BS set speed 1 #menu: Speed > Reset
|
BS set speed 1 #menu: Speed > Reset
|
||||||
|
|
||||||
KP0 script-message rate-file 0 #menu: Addons > Rating > 0stars
|
KP0 script-message rate-file 0 #menu: Extensions > Rating > 0stars
|
||||||
KP1 script-message rate-file 1 #menu: Addons > Rating > 1stars
|
KP1 script-message rate-file 1 #menu: Extensions > Rating > 1stars
|
||||||
KP2 script-message rate-file 2 #menu: Addons > Rating > 2stars
|
KP2 script-message rate-file 2 #menu: Extensions > Rating > 2stars
|
||||||
KP3 script-message rate-file 3 #menu: Addons > Rating > 3stars
|
KP3 script-message rate-file 3 #menu: Extensions > Rating > 3stars
|
||||||
KP4 script-message rate-file 4 #menu: Addons > Rating > 4stars
|
KP4 script-message rate-file 4 #menu: Extensions > Rating > 4stars
|
||||||
KP5 script-message rate-file 5 #menu: Addons > Rating > 5stars
|
KP5 script-message rate-file 5 #menu: Extensions > Rating > 5stars
|
||||||
|
|
||||||
Ctrl+t set ontop yes #menu: View > On Top > Enable
|
Ctrl+t set ontop yes #menu: View > On Top > Enable
|
||||||
Ctrl+T set ontop no #menu: View > On Top > Disable
|
Ctrl+T set ontop no #menu: View > On Top > Disable
|
||||||
|
|||||||
160
mpv.net/mp.cs
160
mpv.net/mp.cs
@@ -53,20 +53,21 @@ namespace mpvnet
|
|||||||
public static event Action QueueOverflow; // MPV_EVENT_QUEUE_OVERFLOW
|
public static event Action QueueOverflow; // MPV_EVENT_QUEUE_OVERFLOW
|
||||||
public static event Action Hook; // MPV_EVENT_HOOK
|
public static event Action Hook; // MPV_EVENT_HOOK
|
||||||
|
|
||||||
public static IntPtr MpvHandle;
|
public static IntPtr MpvHandle { get; set; }
|
||||||
public static IntPtr MpvWindowHandle;
|
public static IntPtr MpvWindowHandle { get; set; }
|
||||||
public static Addon Addon;
|
public static Addon Addon { get; set; }
|
||||||
public static List<KeyValuePair<string, Action<bool>>> BoolPropChangeActions = new List<KeyValuePair<string, Action<bool>>>();
|
public static List<KeyValuePair<string, Action<bool>>> BoolPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<bool>>>();
|
||||||
public static List<KeyValuePair<string, Action<string>>> StringPropChangeActions = new List<KeyValuePair<string, Action<string>>>();
|
public static List<KeyValuePair<string, Action<string>>> StringPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<string>>>();
|
||||||
public static Size VideoSize = new Size(1920, 1080);
|
public static Size VideoSize { get; set; } = new Size(1920, 1080);
|
||||||
public static string mpvConfFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\";
|
public static string MpvConfFolderPath { get; set; } = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\";
|
||||||
public static string InputConfPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\input.conf";
|
public static string InputConfPath { get; set; } = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\input.conf";
|
||||||
public static string mpvConfPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\mpv.conf";
|
public static string MpvConfPath { get; set; } = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\mpv.conf";
|
||||||
public static string mpvNetConfPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\mpvnet.conf";
|
public static string MpvNetConfPath { get; set; } = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\mpvnet.conf";
|
||||||
public static List<PythonScript> PythonScripts => new List<PythonScript>();
|
public static List<PythonScript> PythonScripts { get; set; } = new List<PythonScript>();
|
||||||
public static AutoResetEvent AutoResetEvent = new AutoResetEvent(false);
|
public static AutoResetEvent AutoResetEvent { get; set; } = new AutoResetEvent(false);
|
||||||
|
public static List<MediaTrack> MediaTracks { get; set; } = new List<MediaTrack>();
|
||||||
|
|
||||||
private static Dictionary<string, string> _mpvConf;
|
static Dictionary<string, string> _mpvConf;
|
||||||
|
|
||||||
public static Dictionary<string, string> mpvConf {
|
public static Dictionary<string, string> mpvConf {
|
||||||
get {
|
get {
|
||||||
@@ -74,8 +75,8 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
_mpvConf = new Dictionary<string, string>();
|
_mpvConf = new Dictionary<string, string>();
|
||||||
|
|
||||||
if (File.Exists(mpvConfPath))
|
if (File.Exists(MpvConfPath))
|
||||||
foreach (var i in File.ReadAllLines(mpvConfPath))
|
foreach (var i in File.ReadAllLines(MpvConfPath))
|
||||||
if (i.Contains("=") && ! i.StartsWith("#"))
|
if (i.Contains("=") && ! i.StartsWith("#"))
|
||||||
_mpvConf[i.Substring(0, i.IndexOf("=")).Trim()] = i.Substring(i.IndexOf("=") + 1).Trim();
|
_mpvConf[i.Substring(0, i.IndexOf("=")).Trim()] = i.Substring(i.IndexOf("=") + 1).Trim();
|
||||||
}
|
}
|
||||||
@@ -83,7 +84,7 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<string, string> _mpvNetConf;
|
static Dictionary<string, string> _mpvNetConf;
|
||||||
|
|
||||||
public static Dictionary<string, string> mpvNetConf {
|
public static Dictionary<string, string> mpvNetConf {
|
||||||
get {
|
get {
|
||||||
@@ -91,8 +92,8 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
_mpvNetConf = new Dictionary<string, string>();
|
_mpvNetConf = new Dictionary<string, string>();
|
||||||
|
|
||||||
if (File.Exists(mpvNetConfPath))
|
if (File.Exists(MpvNetConfPath))
|
||||||
foreach (string i in File.ReadAllLines(mpvNetConfPath))
|
foreach (string i in File.ReadAllLines(MpvNetConfPath))
|
||||||
if (i.Contains("=") && !i.StartsWith("#"))
|
if (i.Contains("=") && !i.StartsWith("#"))
|
||||||
_mpvNetConf[i.Substring(0, i.IndexOf("=")).Trim()] = i.Substring(i.IndexOf("=") + 1).Trim();
|
_mpvNetConf[i.Substring(0, i.IndexOf("=")).Trim()] = i.Substring(i.IndexOf("=") + 1).Trim();
|
||||||
}
|
}
|
||||||
@@ -102,11 +103,11 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(mp.mpvConfFolderPath))
|
if (!Directory.Exists(mp.MpvConfFolderPath))
|
||||||
Directory.CreateDirectory(mp.mpvConfFolderPath);
|
Directory.CreateDirectory(mp.MpvConfFolderPath);
|
||||||
|
|
||||||
if (!File.Exists(mp.mpvConfPath))
|
if (!File.Exists(mp.MpvConfPath))
|
||||||
File.WriteAllText(mp.mpvConfPath, Properties.Resources.mpv_conf);
|
File.WriteAllText(mp.MpvConfPath, Properties.Resources.mpv_conf);
|
||||||
|
|
||||||
if (!File.Exists(mp.InputConfPath))
|
if (!File.Exists(mp.InputConfPath))
|
||||||
File.WriteAllText(mp.InputConfPath, Properties.Resources.input_conf);
|
File.WriteAllText(mp.InputConfPath, Properties.Resources.input_conf);
|
||||||
@@ -143,7 +144,7 @@ namespace mpvnet
|
|||||||
if (Path.GetExtension(scriptPath) == ".ps1")
|
if (Path.GetExtension(scriptPath) == ".ps1")
|
||||||
PowerShellScript.Init(scriptPath);
|
PowerShellScript.Init(scriptPath);
|
||||||
|
|
||||||
foreach (var scriptPath in Directory.GetFiles(mp.mpvConfFolderPath + "Scripts"))
|
foreach (var scriptPath in Directory.GetFiles(mp.MpvConfFolderPath + "Scripts"))
|
||||||
if (Path.GetExtension(scriptPath) == ".py")
|
if (Path.GetExtension(scriptPath) == ".py")
|
||||||
PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath)));
|
PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath)));
|
||||||
else if (Path.GetExtension(scriptPath) == ".ps1")
|
else if (Path.GetExtension(scriptPath) == ".ps1")
|
||||||
@@ -168,6 +169,7 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
case mpv_event_id.MPV_EVENT_SHUTDOWN:
|
case mpv_event_id.MPV_EVENT_SHUTDOWN:
|
||||||
Shutdown?.Invoke();
|
Shutdown?.Invoke();
|
||||||
|
WriteHistory(null);
|
||||||
AutoResetEvent.Set();
|
AutoResetEvent.Set();
|
||||||
return;
|
return;
|
||||||
case mpv_event_id.MPV_EVENT_LOG_MESSAGE:
|
case mpv_event_id.MPV_EVENT_LOG_MESSAGE:
|
||||||
@@ -276,6 +278,11 @@ namespace mpvnet
|
|||||||
VideoSize = s;
|
VideoSize = s;
|
||||||
VideoSizeChanged?.Invoke();
|
VideoSizeChanged?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Task.Run(new Action(() => {
|
||||||
|
WriteHistory(mp.get_property_string("path"));
|
||||||
|
SetMediaTracks();
|
||||||
|
}));
|
||||||
break;
|
break;
|
||||||
case mpv_event_id.MPV_EVENT_CHAPTER_CHANGE:
|
case mpv_event_id.MPV_EVENT_CHAPTER_CHANGE:
|
||||||
ChapterChange?.Invoke();
|
ChapterChange?.Invoke();
|
||||||
@@ -295,7 +302,7 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<PythonEventObject> PythonEventObjects = new List<PythonEventObject>();
|
static List<PythonEventObject> PythonEventObjects = new List<PythonEventObject>();
|
||||||
|
|
||||||
public static void register_event(string name, PyRT.PythonFunction pyFunc)
|
public static void register_event(string name, PyRT.PythonFunction pyFunc)
|
||||||
{
|
{
|
||||||
@@ -533,9 +540,9 @@ namespace mpvnet
|
|||||||
mp.LoadFolder();
|
mp.LoadFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool WasFolderLoaded;
|
static bool WasFolderLoaded;
|
||||||
|
|
||||||
public static void LoadFolder()
|
static void LoadFolder()
|
||||||
{
|
{
|
||||||
if (WasFolderLoaded)
|
if (WasFolderLoaded)
|
||||||
return;
|
return;
|
||||||
@@ -561,7 +568,7 @@ namespace mpvnet
|
|||||||
WasFolderLoaded = true;
|
WasFolderLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntPtr AllocateUtf8IntPtrArrayWithSentinel(string[] arr, out IntPtr[] byteArrayPointers)
|
static IntPtr AllocateUtf8IntPtrArrayWithSentinel(string[] arr, out IntPtr[] byteArrayPointers)
|
||||||
{
|
{
|
||||||
int numberOfStrings = arr.Length + 1; // add extra element for extra null pointer last (sentinel)
|
int numberOfStrings = arr.Length + 1; // add extra element for extra null pointer last (sentinel)
|
||||||
byteArrayPointers = new IntPtr[numberOfStrings];
|
byteArrayPointers = new IntPtr[numberOfStrings];
|
||||||
@@ -579,7 +586,7 @@ namespace mpvnet
|
|||||||
return rootPointer;
|
return rootPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string[] NativeUtf8StrArray2ManagedStrArray(IntPtr pUnmanagedStringArray, int StringCount)
|
static string[] NativeUtf8StrArray2ManagedStrArray(IntPtr pUnmanagedStringArray, int StringCount)
|
||||||
{
|
{
|
||||||
IntPtr[] pIntPtrArray = new IntPtr[StringCount];
|
IntPtr[] pIntPtrArray = new IntPtr[StringCount];
|
||||||
string[] ManagedStringArray = new string[StringCount];
|
string[] ManagedStringArray = new string[StringCount];
|
||||||
@@ -591,7 +598,7 @@ namespace mpvnet
|
|||||||
return ManagedStringArray;
|
return ManagedStringArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string StringFromNativeUtf8(IntPtr nativeUtf8)
|
static string StringFromNativeUtf8(IntPtr nativeUtf8)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
while (Marshal.ReadByte(nativeUtf8, len) != 0) ++len;
|
while (Marshal.ReadByte(nativeUtf8, len) != 0) ++len;
|
||||||
@@ -600,7 +607,100 @@ namespace mpvnet
|
|||||||
return Encoding.UTF8.GetString(buffer);
|
return Encoding.UTF8.GetString(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] GetUtf8Bytes(string s) => Encoding.UTF8.GetBytes(s + "\0");
|
static byte[] GetUtf8Bytes(string s) => Encoding.UTF8.GetBytes(s + "\0");
|
||||||
|
|
||||||
|
static string LastHistoryPath;
|
||||||
|
static DateTime LastHistoryStartDateTime;
|
||||||
|
|
||||||
|
static void WriteHistory(string filePath)
|
||||||
|
{
|
||||||
|
int totalMinutes = Convert.ToInt32((DateTime.Now - LastHistoryStartDateTime).TotalMinutes);
|
||||||
|
|
||||||
|
if (File.Exists(LastHistoryPath) && totalMinutes > 1)
|
||||||
|
{
|
||||||
|
string historyFilepath = mp.MpvConfFolderPath + "history.txt";
|
||||||
|
|
||||||
|
File.AppendAllText(historyFilepath, DateTime.Now.ToString().Substring(0, 16) +
|
||||||
|
" " + totalMinutes.ToString().PadLeft(3) + " " +
|
||||||
|
Path.GetFileNameWithoutExtension(LastHistoryPath) + "\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
LastHistoryPath = filePath;
|
||||||
|
LastHistoryStartDateTime = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetMediaTracks()
|
||||||
|
{
|
||||||
|
lock (MediaTracks)
|
||||||
|
{
|
||||||
|
MediaTracks.Clear();
|
||||||
|
|
||||||
|
using (MediaInfo mi = new MediaInfo(mp.get_property_string("path")))
|
||||||
|
{
|
||||||
|
int count = mi.GetCount(MediaInfoStreamKind.Video);
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
MediaTrack track = new MediaTrack();
|
||||||
|
Add(track, mi.GetVideo(i, "Format"));
|
||||||
|
Add(track, mi.GetVideo(i, "Format_Profile"));
|
||||||
|
Add(track, mi.GetVideo(i, "Width") + "x" + mi.GetVideo(i, "Height"));
|
||||||
|
Add(track, mi.GetVideo(i, "FrameRate") + " FPS");
|
||||||
|
Add(track, mi.GetVideo(i, "Language/String"));
|
||||||
|
Add(track, mi.GetVideo(i, "Forced") == "Yes" ? "Forced" : "");
|
||||||
|
Add(track, mi.GetVideo(i, "Default") == "Yes" ? "Default" : "");
|
||||||
|
Add(track, mi.GetVideo(i, "Title"));
|
||||||
|
track.Text = "V: " + track.Text.Trim(" ,".ToCharArray());
|
||||||
|
track.Type = "v";
|
||||||
|
track.ID = i + 1;
|
||||||
|
MediaTracks.Add(track);
|
||||||
|
}
|
||||||
|
|
||||||
|
count = mi.GetCount(MediaInfoStreamKind.Audio);
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
MediaTrack track = new MediaTrack();
|
||||||
|
Add(track, mi.GetAudio(i, "Language/String"));
|
||||||
|
Add(track, mi.GetAudio(i, "Format"));
|
||||||
|
Add(track, mi.GetAudio(i, "Format_Profile"));
|
||||||
|
Add(track, mi.GetAudio(i, "BitRate/String"));
|
||||||
|
Add(track, mi.GetAudio(i, "Channel(s)/String"));
|
||||||
|
Add(track, mi.GetAudio(i, "SamplingRate/String"));
|
||||||
|
Add(track, mi.GetAudio(i, "Forced") == "Yes" ? "Forced" : "");
|
||||||
|
Add(track, mi.GetAudio(i, "Default") == "Yes" ? "Default" : "");
|
||||||
|
Add(track, mi.GetAudio(i, "Title"));
|
||||||
|
track.Text = "A: " + track.Text.Trim(" ,".ToCharArray());
|
||||||
|
track.Type = "a";
|
||||||
|
track.ID = i + 1;
|
||||||
|
MediaTracks.Add(track);
|
||||||
|
}
|
||||||
|
|
||||||
|
count = mi.GetCount(MediaInfoStreamKind.Text);
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
MediaTrack track = new MediaTrack();
|
||||||
|
Add(track, mi.GetText(i, "Language/String"));
|
||||||
|
Add(track, mi.GetText(i, "Format"));
|
||||||
|
Add(track, mi.GetText(i, "Format_Profile"));
|
||||||
|
Add(track, mi.GetText(i, "Forced") == "Yes" ? "Forced" : "");
|
||||||
|
Add(track, mi.GetText(i, "Default") == "Yes" ? "Default" : "");
|
||||||
|
Add(track, mi.GetText(i, "Title"));
|
||||||
|
track.Text = "S: " + track.Text.Trim(" ,".ToCharArray());
|
||||||
|
track.Type = "s";
|
||||||
|
track.ID = i + 1;
|
||||||
|
MediaTracks.Add(track);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Add(MediaTrack track, string val)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(val) && !(track.Text != null && track.Text.Contains(val)))
|
||||||
|
track.Text += " " + val + ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum EndFileEventMode
|
public enum EndFileEventMode
|
||||||
|
|||||||
Reference in New Issue
Block a user