This repository has been archived by the owner on May 6, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
49 lines (48 loc) · 1.58 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
namespace Nickvision.MPVSharp.Examples.Simple;
public class Program
{
public static int Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine($"Usage: {AppDomain.CurrentDomain.FriendlyName} file1 file2...");
return 1;
}
// Create and init player
using var player = new Client();
player.SetProperty("input-default-bindings", true);
player.SetProperty("input-vo-keyboard", true);
player.SetProperty("ytdl", true);
player.SetProperty("osc", false);
player.SetProperty("osd-msg1", "Position: ${time-pos}");
player.Initialize();
// Add paths to playlist and play
foreach (var path in args)
{
Console.WriteLine($"Adding {path}...");
player.LoadFile(path, LoadFlags.Append);
}
player.Command("playlist-play-index 0");
var alive = true;
// Watch properties
player.PropertyChanged += (sender, e) =>
{
Console.WriteLine($"{e.Name}: {e.Node.ToString()}");
};
player.ObserveProperty("playlist-pos");
player.ObserveProperty("filename/no-ext");
// Enable logging
player.RequestLogMessages("info");
player.LogMessageReceived += (sender, e) =>
{
Console.Write($"[{e.Prefix}] {e.Text}"); // Log messages (e.Text) end with newline char
};
// Application loop
player.Destroyed += () => alive = false;
while (alive)
{
Thread.Sleep(1000);
}
return 0;
}
}