-
This commit is contained in:
@@ -73,11 +73,14 @@ Scripting is supported via Python, C#, Lua, JavaScript and PowerShell
|
|||||||
|
|
||||||
### Changelog
|
### Changelog
|
||||||
|
|
||||||
### 3.0 (20??-??-??)
|
### 3.0 (2019-04-20)
|
||||||
|
|
||||||
- the history feature logs only files that were opened longer than 90 seconds
|
- the history feature logs now only files that were opened longer than 90 seconds
|
||||||
- the default input command for cycling the audio tracks was replaced with an
|
- 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
|
mpv.net command that shows detailed track info and has no 'no audio' track
|
||||||
|
- new web site for mpv.net <https://mpv-net.github.io/mpv.net-web-site/>
|
||||||
|
- the tracks menu supports now mkv edition selection
|
||||||
|
- the Navigate menu supports now chapter selection
|
||||||
|
|
||||||
[go to download page](https://github.com/stax76/mpv.net/releases)
|
[go to download page](https://github.com/stax76/mpv.net/releases)
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ using System.Threading;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
using VBNET;
|
using VBNET;
|
||||||
using System.Threading.Tasks;
|
using System.Globalization;
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace mpvnet
|
namespace mpvnet
|
||||||
{
|
{
|
||||||
@@ -19,11 +19,14 @@ namespace mpvnet
|
|||||||
public static IntPtr Hwnd { get; set; }
|
public static IntPtr Hwnd { get; set; }
|
||||||
|
|
||||||
public new ContextMenuStripEx ContextMenu;
|
public new ContextMenuStripEx ContextMenu;
|
||||||
|
|
||||||
MenuItemEx TracksMenu;
|
MenuItemEx TracksMenu;
|
||||||
|
MenuItemEx ChaptersMenu;
|
||||||
|
|
||||||
Point LastCursorPosChanged;
|
Point LastCursorPosChanged;
|
||||||
int LastCursorChangedTickCount;
|
int LastCursorChangedTickCount;
|
||||||
bool IgnoreDpiChanged = true;
|
bool IgnoreDpiChanged = true;
|
||||||
|
|
||||||
float MpvAutofit = 0.50f;
|
float MpvAutofit = 0.50f;
|
||||||
bool MpvFullscreen;
|
bool MpvFullscreen;
|
||||||
int MpvScreen = -1;
|
int MpvScreen = -1;
|
||||||
@@ -31,6 +34,7 @@ namespace mpvnet
|
|||||||
string MpvSid = "";
|
string MpvSid = "";
|
||||||
string MpvAid = "";
|
string MpvAid = "";
|
||||||
string MpvVid = "";
|
string MpvVid = "";
|
||||||
|
int MpvEdition;
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
@@ -70,15 +74,17 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
lock (mp.MediaTracks)
|
lock (mp.MediaTracks)
|
||||||
{
|
{
|
||||||
TracksMenu.DropDownItems.Clear();
|
if (TracksMenu != null)
|
||||||
|
TracksMenu.DropDownItems.Clear();
|
||||||
|
|
||||||
MediaTrack[] audTracks = mp.MediaTracks.Where(track => track.Type == "a").ToArray();
|
MediaTrack[] audTracks = mp.MediaTracks.Where(track => track.Type == "a").ToArray();
|
||||||
MediaTrack[] subTracks = mp.MediaTracks.Where(track => track.Type == "s").ToArray();
|
MediaTrack[] subTracks = mp.MediaTracks.Where(track => track.Type == "s").ToArray();
|
||||||
MediaTrack[] vidTracks = mp.MediaTracks.Where(track => track.Type == "v").ToArray();
|
MediaTrack[] vidTracks = mp.MediaTracks.Where(track => track.Type == "v").ToArray();
|
||||||
|
MediaTrack[] ediTracks = mp.MediaTracks.Where(track => track.Type == "e").ToArray();
|
||||||
|
|
||||||
foreach (MediaTrack track in vidTracks)
|
foreach (MediaTrack track in vidTracks)
|
||||||
{
|
{
|
||||||
var mi = ContextMenu.Add("Track > " + track.Text);
|
MenuItemEx mi = ContextMenu.Add("Track > " + track.Text);
|
||||||
mi.Action = () => { mp.commandv("set", "vid", track.ID.ToString()); };
|
mi.Action = () => { mp.commandv("set", "vid", track.ID.ToString()); };
|
||||||
mi.Checked = MpvVid == track.ID.ToString();
|
mi.Checked = MpvVid == track.ID.ToString();
|
||||||
}
|
}
|
||||||
@@ -88,7 +94,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
foreach (MediaTrack track in audTracks)
|
foreach (MediaTrack track in audTracks)
|
||||||
{
|
{
|
||||||
var mi = ContextMenu.Add("Track > " + track.Text);
|
MenuItemEx mi = ContextMenu.Add("Track > " + track.Text);
|
||||||
mi.Action = () => { mp.commandv("set", "aid", track.ID.ToString()); };
|
mi.Action = () => { mp.commandv("set", "aid", track.ID.ToString()); };
|
||||||
mi.Checked = MpvAid == track.ID.ToString();
|
mi.Checked = MpvAid == track.ID.ToString();
|
||||||
}
|
}
|
||||||
@@ -98,17 +104,40 @@ namespace mpvnet
|
|||||||
|
|
||||||
foreach (MediaTrack track in subTracks)
|
foreach (MediaTrack track in subTracks)
|
||||||
{
|
{
|
||||||
var mi = ContextMenu.Add("Track > " + track.Text);
|
MenuItemEx mi = ContextMenu.Add("Track > " + track.Text);
|
||||||
mi.Action = () => { mp.commandv("set", "sid", track.ID.ToString()); };
|
mi.Action = () => { mp.commandv("set", "sid", track.ID.ToString()); };
|
||||||
mi.Checked = MpvSid == track.ID.ToString();
|
mi.Checked = MpvSid == track.ID.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subTracks.Length > 0)
|
if (subTracks.Length > 0)
|
||||||
{
|
{
|
||||||
var mi = ContextMenu.Add("Track > S: No subtitles");
|
MenuItemEx mi = ContextMenu.Add("Track > S: No subtitles");
|
||||||
mi.Action = () => { mp.commandv("set", "sid", "no"); };
|
mi.Action = () => { mp.commandv("set", "sid", "no"); };
|
||||||
mi.Checked = MpvSid == "no";
|
mi.Checked = MpvSid == "no";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ediTracks.Length > 0)
|
||||||
|
ContextMenu.Add("Track > -");
|
||||||
|
|
||||||
|
foreach (MediaTrack track in ediTracks)
|
||||||
|
{
|
||||||
|
MenuItemEx mi = ContextMenu.Add("Track > " + track.Text);
|
||||||
|
mi.Action = () => { mp.commandv("set", "edition", track.ID.ToString()); };
|
||||||
|
mi.Checked = MpvEdition == track.ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (mp.Chapters)
|
||||||
|
{
|
||||||
|
if (ChaptersMenu != null)
|
||||||
|
ChaptersMenu.DropDownItems.Clear();
|
||||||
|
|
||||||
|
foreach (var i in mp.Chapters)
|
||||||
|
{
|
||||||
|
MenuItemEx mi = ContextMenu.Add("Navigate > Chapters > " + i.Key);
|
||||||
|
mi.ShortcutKeyDisplayString = TimeSpan.FromSeconds(i.Value).ToString() + " ";
|
||||||
|
mi.Action = () => { mp.commandv("seek", i.Value.ToString(CultureInfo.InvariantCulture), "absolute"); };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,6 +308,11 @@ namespace mpvnet
|
|||||||
menuItem.Text.Trim() == "Track")
|
menuItem.Text.Trim() == "Track")
|
||||||
|
|
||||||
TracksMenu = menuItem;
|
TracksMenu = menuItem;
|
||||||
|
|
||||||
|
if (ChaptersMenu == null && menuItem.Text.StartsWith("Chapters ") &&
|
||||||
|
menuItem.Text.Trim() == "Chapters")
|
||||||
|
|
||||||
|
ChaptersMenu = menuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -467,6 +501,7 @@ namespace mpvnet
|
|||||||
mp.observe_property_string("sid", mpPropChangeSid);
|
mp.observe_property_string("sid", mpPropChangeSid);
|
||||||
mp.observe_property_string("aid", mpPropChangeAid);
|
mp.observe_property_string("aid", mpPropChangeAid);
|
||||||
mp.observe_property_string("vid", mpPropChangeVid);
|
mp.observe_property_string("vid", mpPropChangeVid);
|
||||||
|
mp.observe_property_int("edition", mpPropChangeEdition);
|
||||||
mp.Shutdown += mp_Shutdown;
|
mp.Shutdown += mp_Shutdown;
|
||||||
mp.VideoSizeChanged += mp_VideoSizeChanged;
|
mp.VideoSizeChanged += mp_VideoSizeChanged;
|
||||||
mp.PlaybackRestart += mp_PlaybackRestart;
|
mp.PlaybackRestart += mp_PlaybackRestart;
|
||||||
@@ -481,6 +516,8 @@ namespace mpvnet
|
|||||||
|
|
||||||
void mpPropChangeVid(string value) => MpvVid = value;
|
void mpPropChangeVid(string value) => MpvVid = value;
|
||||||
|
|
||||||
|
void mpPropChangeEdition(int value) => MpvEdition = value;
|
||||||
|
|
||||||
protected override void OnShown(EventArgs e)
|
protected override void OnShown(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnShown(e);
|
base.OnShown(e);
|
||||||
|
|||||||
@@ -136,6 +136,6 @@ namespace mpvnet
|
|||||||
{
|
{
|
||||||
public string Text { get; set; }
|
public string Text { get; set; }
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.9.0.0")]
|
[assembly: AssemblyVersion("3.0.0.0")]
|
||||||
[assembly: AssemblyFileVersion("2.9.0.0")]
|
[assembly: AssemblyFileVersion("3.0.0.0")]
|
||||||
|
|||||||
@@ -53,6 +53,8 @@
|
|||||||
_ ignore #menu: Navigate > -
|
_ ignore #menu: Navigate > -
|
||||||
Ctrl+Right no-osd seek 300 #menu: Navigate > Jump 5 min forward
|
Ctrl+Right no-osd seek 300 #menu: Navigate > Jump 5 min forward
|
||||||
Ctrl+Left no-osd seek -300 #menu: Navigate > Jump 5 min backward
|
Ctrl+Left no-osd seek -300 #menu: Navigate > Jump 5 min backward
|
||||||
|
_ ignore #menu: Navigate > -
|
||||||
|
_ ignore #menu: Navigate > Chapters
|
||||||
|
|
||||||
Ctrl++ add video-zoom 0.1 #menu: Pan & Scan > Increase Size
|
Ctrl++ add video-zoom 0.1 #menu: Pan & Scan > Increase Size
|
||||||
Ctrl+- add video-zoom -0.1 #menu: Pan & Scan > Decrease Size
|
Ctrl+- add video-zoom -0.1 #menu: Pan & Scan > Decrease Size
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ namespace mpvnet
|
|||||||
public static IntPtr MpvWindowHandle { get; set; }
|
public static IntPtr MpvWindowHandle { get; set; }
|
||||||
public static Addon Addon { get; set; }
|
public static Addon Addon { get; set; }
|
||||||
public static List<KeyValuePair<string, Action<bool>>> BoolPropChangeActions { get; set; } = 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<int>>> IntPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<int>>>();
|
||||||
public static List<KeyValuePair<string, Action<string>>> StringPropChangeActions { get; set; } = 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 { get; set; } = new Size(1920, 1080);
|
public static Size VideoSize { get; set; } = new Size(1920, 1080);
|
||||||
public static string MpvConfFolderPath { get; set; } = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\";
|
public static string MpvConfFolderPath { get; set; } = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\";
|
||||||
@@ -66,6 +67,7 @@ namespace mpvnet
|
|||||||
public static List<PythonScript> PythonScripts { get; set; } = new List<PythonScript>();
|
public static List<PythonScript> PythonScripts { get; set; } = new List<PythonScript>();
|
||||||
public static AutoResetEvent AutoResetEvent { get; set; } = new AutoResetEvent(false);
|
public static AutoResetEvent AutoResetEvent { get; set; } = new AutoResetEvent(false);
|
||||||
public static List<MediaTrack> MediaTracks { get; set; } = new List<MediaTrack>();
|
public static List<MediaTrack> MediaTracks { get; set; } = new List<MediaTrack>();
|
||||||
|
public static List<KeyValuePair<string, double>> Chapters { get; set; } = new List<KeyValuePair<string, double>>();
|
||||||
|
|
||||||
static Dictionary<string, string> _mpvConf;
|
static Dictionary<string, string> _mpvConf;
|
||||||
|
|
||||||
@@ -268,6 +270,11 @@ namespace mpvnet
|
|||||||
foreach (var i in StringPropChangeActions)
|
foreach (var i in StringPropChangeActions)
|
||||||
if (i.Key == propData.name)
|
if (i.Key == propData.name)
|
||||||
i.Value.Invoke(StringFromNativeUtf8(Marshal.PtrToStructure<IntPtr>(propData.data)));
|
i.Value.Invoke(StringFromNativeUtf8(Marshal.PtrToStructure<IntPtr>(propData.data)));
|
||||||
|
|
||||||
|
if (propData.format == mpv_format.MPV_FORMAT_INT64)
|
||||||
|
foreach (var i in IntPropChangeActions)
|
||||||
|
if (i.Key == propData.name)
|
||||||
|
i.Value.Invoke(Marshal.PtrToStructure<int>(propData.data));
|
||||||
break;
|
break;
|
||||||
case mpv_event_id.MPV_EVENT_PLAYBACK_RESTART:
|
case mpv_event_id.MPV_EVENT_PLAYBACK_RESTART:
|
||||||
PlaybackRestart?.Invoke();
|
PlaybackRestart?.Invoke();
|
||||||
@@ -281,7 +288,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
Task.Run(new Action(() => {
|
Task.Run(new Action(() => {
|
||||||
WriteHistory(mp.get_property_string("path"));
|
WriteHistory(mp.get_property_string("path"));
|
||||||
SetMediaTracks();
|
ReadMetaData();
|
||||||
}));
|
}));
|
||||||
break;
|
break;
|
||||||
case mpv_event_id.MPV_EVENT_CHAPTER_CHANGE:
|
case mpv_event_id.MPV_EVENT_CHAPTER_CHANGE:
|
||||||
@@ -444,6 +451,16 @@ namespace mpvnet
|
|||||||
throw new Exception($"{name}: {(mpv_error)err}");
|
throw new Exception($"{name}: {(mpv_error)err}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void observe_property_int(string name, Action<int> action)
|
||||||
|
{
|
||||||
|
int err = mpv_observe_property(MpvHandle, (ulong)action.GetHashCode(), name, mpv_format.MPV_FORMAT_INT64);
|
||||||
|
|
||||||
|
if (err < 0)
|
||||||
|
throw new Exception($"{name}: {(mpv_error)err}");
|
||||||
|
else
|
||||||
|
IntPropChangeActions.Add(new KeyValuePair<string, Action<int>>(name, action));
|
||||||
|
}
|
||||||
|
|
||||||
public static void observe_property_bool(string name, Action<bool> action)
|
public static void observe_property_bool(string name, Action<bool> action)
|
||||||
{
|
{
|
||||||
int err = mpv_observe_property(MpvHandle, (ulong)action.GetHashCode(), name, mpv_format.MPV_FORMAT_FLAG);
|
int err = mpv_observe_property(MpvHandle, (ulong)action.GetHashCode(), name, mpv_format.MPV_FORMAT_FLAG);
|
||||||
@@ -454,18 +471,6 @@ namespace mpvnet
|
|||||||
BoolPropChangeActions.Add(new KeyValuePair<string, Action<bool>>(name, action));
|
BoolPropChangeActions.Add(new KeyValuePair<string, Action<bool>>(name, action));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unobserve_property_bool(string name, Action<bool> action)
|
|
||||||
{
|
|
||||||
foreach (var i in BoolPropChangeActions.ToArray())
|
|
||||||
if (i.Value == action)
|
|
||||||
BoolPropChangeActions.Remove(i);
|
|
||||||
|
|
||||||
int err = mpv_unobserve_property(MpvHandle, (ulong)action.GetHashCode());
|
|
||||||
|
|
||||||
if (err < 0)
|
|
||||||
throw new Exception($"{name}: {(mpv_error)err}");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void observe_property_string(string name, Action<string> action)
|
public static void observe_property_string(string name, Action<string> action)
|
||||||
{
|
{
|
||||||
int err = mpv_observe_property(MpvHandle, (ulong)action.GetHashCode(), name, mpv_format.MPV_FORMAT_STRING);
|
int err = mpv_observe_property(MpvHandle, (ulong)action.GetHashCode(), name, mpv_format.MPV_FORMAT_STRING);
|
||||||
@@ -476,18 +481,6 @@ namespace mpvnet
|
|||||||
StringPropChangeActions.Add(new KeyValuePair<string, Action<string>>(name, action));
|
StringPropChangeActions.Add(new KeyValuePair<string, Action<string>>(name, action));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unobserve_property_string(string name, Action<string> action)
|
|
||||||
{
|
|
||||||
foreach (var i in StringPropChangeActions.ToArray())
|
|
||||||
if (i.Value == action)
|
|
||||||
StringPropChangeActions.Remove(i);
|
|
||||||
|
|
||||||
int err = mpv_unobserve_property(MpvHandle, (ulong)action.GetHashCode());
|
|
||||||
|
|
||||||
if (err < 0)
|
|
||||||
throw new Exception($"{name}: {(mpv_error)err}");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void ProcessCommandLine()
|
protected static void ProcessCommandLine()
|
||||||
{
|
{
|
||||||
var args = Environment.GetCommandLineArgs().Skip(1);
|
var args = Environment.GetCommandLineArgs().Skip(1);
|
||||||
@@ -629,7 +622,7 @@ namespace mpvnet
|
|||||||
LastHistoryStartDateTime = DateTime.Now;
|
LastHistoryStartDateTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetMediaTracks()
|
static void ReadMetaData()
|
||||||
{
|
{
|
||||||
lock (MediaTracks)
|
lock (MediaTracks)
|
||||||
{
|
{
|
||||||
@@ -693,6 +686,17 @@ namespace mpvnet
|
|||||||
MediaTracks.Add(track);
|
MediaTracks.Add(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count = get_property_int("edition-list/count");
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
MediaTrack track = new MediaTrack();
|
||||||
|
track.Text = "E: " + get_property_string($"edition-list/{i}/title");
|
||||||
|
track.Type = "e";
|
||||||
|
track.ID = i;
|
||||||
|
MediaTracks.Add(track);
|
||||||
|
}
|
||||||
|
|
||||||
void Add(MediaTrack track, string val)
|
void Add(MediaTrack track, string val)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(val) && !(track.Text != null && track.Text.Contains(val)))
|
if (!string.IsNullOrEmpty(val) && !(track.Text != null && track.Text.Contains(val)))
|
||||||
@@ -700,6 +704,19 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lock (Chapters)
|
||||||
|
{
|
||||||
|
Chapters.Clear();
|
||||||
|
int count = get_property_int("chapter-list/count");
|
||||||
|
|
||||||
|
for (int x = 0; x < count; x++)
|
||||||
|
{
|
||||||
|
string text = get_property_string($"chapter-list/{x}/title");
|
||||||
|
double time = get_property_number($"chapter-list/{x}/time");
|
||||||
|
Chapters.Add(new KeyValuePair<string, double>(text, time));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user