Compare commits
364 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57ae0d008b | ||
|
|
e128a4868b | ||
|
|
3875e1c1bf | ||
|
|
dd508907eb | ||
|
|
765854cd10 | ||
|
|
69fe7c091a | ||
|
|
45a2b7f976 | ||
|
|
a8cf3407e7 | ||
|
|
b8163c3c3e | ||
|
|
9d27465492 | ||
|
|
bba71c3782 | ||
|
|
eaa8a3ca6c | ||
|
|
0b28770d1a | ||
|
|
45d3386a88 | ||
|
|
8df330b7aa | ||
|
|
69857e0548 | ||
|
|
b1388e10e5 | ||
|
|
6f7f127279 | ||
|
|
18c8f5783b | ||
|
|
cdf3eb1373 | ||
|
|
e5bcd0fc29 | ||
|
|
b0dc44a98e | ||
|
|
41a14cd3b7 | ||
|
|
b38c7cf834 | ||
|
|
2ee4c1e647 | ||
|
|
2bcf97a97a | ||
|
|
8eaec77b0c | ||
|
|
3161ba1022 | ||
|
|
496bba71d4 | ||
|
|
3e1e822e56 | ||
|
|
b1ea6da39b | ||
|
|
8d54abae4c | ||
|
|
3583aa11ed | ||
|
|
642c36bacf | ||
|
|
0343b32847 | ||
|
|
6e2d11952f | ||
|
|
d0ad69656a | ||
|
|
62789fa036 | ||
|
|
a7fe444067 | ||
|
|
1ef4740b09 | ||
|
|
c5e445da17 | ||
|
|
a52de9039d | ||
|
|
8db8e497a5 | ||
|
|
28c9b2710c | ||
|
|
6ba9b1f05a | ||
|
|
ea5d3e64ee | ||
|
|
636d28ac54 | ||
|
|
6e54286a60 | ||
|
|
b396012934 | ||
|
|
f3909acdfe | ||
|
|
3ed71444a7 | ||
|
|
cab7c6d49b | ||
|
|
368641523a | ||
|
|
42c76d25c6 | ||
|
|
3968fa50f5 | ||
|
|
4d985c7b7c | ||
|
|
235a52a701 | ||
|
|
9a63b660de | ||
|
|
8eb0222873 | ||
|
|
bf8636135a | ||
|
|
33cdee5497 | ||
|
|
564d7b10a0 | ||
|
|
a1a408da1d | ||
|
|
85a3506403 | ||
|
|
e860cf52c4 | ||
|
|
32a46e47e2 | ||
|
|
538e91aaa9 | ||
|
|
94eaf8144f | ||
|
|
404a8f110d | ||
|
|
14f5228754 | ||
|
|
5ec2d1b436 | ||
|
|
32c6ce3a44 | ||
|
|
b86148dfb3 | ||
|
|
26e94fad2b | ||
|
|
c306eb032f | ||
|
|
09944583dd | ||
|
|
8f4ad52469 | ||
|
|
5f4eca21e5 | ||
|
|
b4632a0b6e | ||
|
|
c14a11170d | ||
|
|
723005b28f | ||
|
|
72f25a686e | ||
|
|
b1fb940759 | ||
|
|
1020cd70d1 | ||
|
|
50a2f13dbe | ||
|
|
b1ffb8291f | ||
|
|
dbc8ddaf2b | ||
|
|
b42cb6be05 | ||
|
|
b63363336f | ||
|
|
b0ef161ed9 | ||
|
|
7d31237d5f | ||
|
|
3705e2abbf | ||
|
|
7d73529c83 | ||
|
|
2e59d49ad1 | ||
|
|
f61eef8961 | ||
|
|
efb4c085d5 | ||
|
|
4a045d6a91 | ||
|
|
da1a78cfa3 | ||
|
|
5b3697fbde | ||
|
|
726d759589 | ||
|
|
ed614332f7 | ||
|
|
9d46064dca | ||
|
|
407b49b3ad | ||
|
|
0e92d4ec0c | ||
|
|
4f96835e19 | ||
|
|
56d954d94e | ||
|
|
a8aeb1e3e9 | ||
|
|
415fd266a2 | ||
|
|
51f9e17380 | ||
|
|
28045ad33e | ||
|
|
e1bd44cd00 | ||
|
|
27d6026213 | ||
|
|
c67d5f10f8 | ||
|
|
5f73be07e8 | ||
|
|
0cad09d2bb | ||
|
|
54b2612bb8 | ||
|
|
82b4d19282 | ||
|
|
23a587c819 | ||
|
|
d69eecd494 | ||
|
|
0d4cc59f9a | ||
|
|
a394536a8c | ||
|
|
ebcd20ceb5 | ||
|
|
964c2f4dd2 | ||
|
|
e985047a54 | ||
|
|
bafc09a948 | ||
|
|
14a172b78b | ||
|
|
2eb324bf41 | ||
|
|
afe9ad5128 | ||
|
|
cc657d4ec2 | ||
|
|
1270dd474e | ||
|
|
e9ea70838d | ||
|
|
e7fde60150 | ||
|
|
2028113d58 | ||
|
|
4d55423fc7 | ||
|
|
d82874409d | ||
|
|
930ba2b0e7 | ||
|
|
4743f365a1 | ||
|
|
194ff5d62b | ||
|
|
5a726a01e0 | ||
|
|
fee13353ec | ||
|
|
cd3543fff4 | ||
|
|
c54f240346 | ||
|
|
7f55ad908a | ||
|
|
d586a82e37 | ||
|
|
722e06a02b | ||
|
|
2f76d2b775 | ||
|
|
7519977124 | ||
|
|
2e65b9ceb8 | ||
|
|
04bffca206 | ||
|
|
ff5a164c69 | ||
|
|
26b391a8d9 | ||
|
|
32eed33c82 | ||
|
|
639893f2e7 | ||
|
|
42b0cc1a64 | ||
|
|
6f7fa6c9d6 | ||
|
|
e6fb775dcd | ||
|
|
ece15ca9bb | ||
|
|
6b3c2788df | ||
|
|
067bdd20d7 | ||
|
|
97ce08c4c7 | ||
|
|
fbb9cbdc33 | ||
|
|
815adca198 | ||
|
|
ce3d5792ad | ||
|
|
74fc0b3ed7 | ||
|
|
604a1e8499 | ||
|
|
56ade0a0d1 | ||
|
|
6294a96aea | ||
|
|
9a95953a04 | ||
|
|
8d9c0c9092 | ||
|
|
e399ca672f | ||
|
|
660345d18a | ||
|
|
3844db6e79 | ||
|
|
5374e20757 | ||
|
|
bc6167c4ee | ||
|
|
7979f77284 | ||
|
|
71b90ed5cb | ||
|
|
9d2e236b3e | ||
|
|
d42657a3f0 | ||
|
|
e4818fae18 | ||
|
|
7b39bfcbc4 | ||
|
|
fd6f3c94dd | ||
|
|
dd10c07fb5 | ||
|
|
3bbfdcffdd | ||
|
|
6b7c4e1724 | ||
|
|
d3ad1091ec | ||
|
|
65177c448b | ||
|
|
1cdecb3810 | ||
|
|
20ea755a93 | ||
|
|
3b7bc95869 | ||
|
|
5380daad53 | ||
|
|
a5f4d848d4 | ||
|
|
cf0f9bfa01 | ||
|
|
68461e05da | ||
|
|
397b988851 | ||
|
|
eddb95e791 | ||
|
|
fa1183710b | ||
|
|
f468fd9c56 | ||
|
|
22f2aa93a8 | ||
|
|
c2c0a8f190 | ||
|
|
da3e6655c6 | ||
|
|
856959a4d1 | ||
|
|
9053ecb4ee | ||
|
|
33fd7fc09b | ||
|
|
d005f19755 | ||
|
|
1081007009 | ||
|
|
e6c0a67483 | ||
|
|
265e18985d | ||
|
|
8dc204e81a | ||
|
|
b9b604bfe3 | ||
|
|
05027cd458 | ||
|
|
9bbde49a5c | ||
|
|
cfca7786f3 | ||
|
|
be57edf2c5 | ||
|
|
f48901355a | ||
|
|
ca153fecfc | ||
|
|
e3227de8b4 | ||
|
|
4a202245b5 | ||
|
|
b94f9de582 | ||
|
|
7371949730 | ||
|
|
857926696c | ||
|
|
4451a6c185 | ||
|
|
ea6a71b7c3 | ||
|
|
625dddcfbb | ||
|
|
0cd769fc0c | ||
|
|
f5e0c92824 | ||
|
|
327a097bcf | ||
|
|
68626fa536 | ||
|
|
8935101058 | ||
|
|
6947c925b9 | ||
|
|
4562131078 | ||
|
|
21188f0942 | ||
|
|
1316559ebc | ||
|
|
cd576f9211 | ||
|
|
1bac8e8937 | ||
|
|
e6d0449f8f | ||
|
|
e0e40b7918 | ||
|
|
b59f16a425 | ||
|
|
46b110d93b | ||
|
|
7e8a654ada | ||
|
|
c2c33228a0 | ||
|
|
0a28f13d51 | ||
|
|
9f3a1da931 | ||
|
|
05874ad6be | ||
|
|
078e8046bd | ||
|
|
b07901485e | ||
|
|
a37cbef8a8 | ||
|
|
8debcc171c | ||
|
|
e230f0f474 | ||
|
|
558bd67591 | ||
|
|
a7e4892acf | ||
|
|
a0ba69c1aa | ||
|
|
1e7e80577d | ||
|
|
2177308b02 | ||
|
|
a8c2409ed1 | ||
|
|
1ef9e64a41 | ||
|
|
f0546485cf | ||
|
|
032e91e4b4 | ||
|
|
1447636eb7 | ||
|
|
966f96a02b | ||
|
|
954c014708 | ||
|
|
ad30dc5ae2 | ||
|
|
3f74344b99 | ||
|
|
96d8d88d09 | ||
|
|
8626b8283f | ||
|
|
d90025e8fe | ||
|
|
a572bd8553 | ||
|
|
0f5146e58c | ||
|
|
9c6c0f3506 | ||
|
|
8c36cc8b8c | ||
|
|
44435057d7 | ||
|
|
135bdeb638 | ||
|
|
93c93b620d | ||
|
|
247aefbf07 | ||
|
|
0a8397652f | ||
|
|
ecd5b01161 | ||
|
|
1e9893977d | ||
|
|
4fd6b13e0f | ||
|
|
d21d36c196 | ||
|
|
fbffbea641 | ||
|
|
9899c2cd27 | ||
|
|
10370e9ae2 | ||
|
|
d391e24784 | ||
|
|
430fef0ac4 | ||
|
|
8430842679 | ||
|
|
9d37e67901 | ||
|
|
e98ff53058 | ||
|
|
b47d3c34f2 | ||
|
|
54dd261df0 | ||
|
|
8eb7e41d16 | ||
|
|
2068bfb6fa | ||
|
|
dfc1ac712e | ||
|
|
d96587cb7b | ||
|
|
005550af55 | ||
|
|
543e2905cc | ||
|
|
a49b9bea61 | ||
|
|
9ea9cb2757 | ||
|
|
5543381a14 | ||
|
|
cd6dcf4640 | ||
|
|
d321ab477f | ||
|
|
1cd0f87278 | ||
|
|
936274fc3b | ||
|
|
2bbaa30322 | ||
|
|
cedd54d64d | ||
|
|
38604459a6 | ||
|
|
0a48a0dc6f | ||
|
|
85a23fbae1 | ||
|
|
01da76bdc4 | ||
|
|
1f1553e159 | ||
|
|
2af84941ca | ||
|
|
a82f558acf | ||
|
|
d13f7201ba | ||
|
|
89aa0c6133 | ||
|
|
1699467e0d | ||
|
|
7a27ab0513 | ||
|
|
2a0c68e4ec | ||
|
|
91c42d4d3f | ||
|
|
49d56166d7 | ||
|
|
1ac603b904 | ||
|
|
d5b2923c68 | ||
|
|
b80b375df1 | ||
|
|
2b2b60b90f | ||
|
|
3977283ecb | ||
|
|
d27778775d | ||
|
|
5c053bb5eb | ||
|
|
83658aa476 | ||
|
|
e0111b6f12 | ||
|
|
e308bbf928 | ||
|
|
1817fbc0fd | ||
|
|
3b149aea54 | ||
|
|
7575a2d736 | ||
|
|
17c198e711 | ||
|
|
1f8635e9c4 | ||
|
|
37e6c198a1 | ||
|
|
751c8779f4 | ||
|
|
9e2bf46636 | ||
|
|
3529323d93 | ||
|
|
ba52c1f8b5 | ||
|
|
bf2070d758 | ||
|
|
7a1de4cf0f | ||
|
|
caf0bee161 | ||
|
|
cedd694e8e | ||
|
|
d1c58585f5 | ||
|
|
0fce626c46 | ||
|
|
adb8f38c0d | ||
|
|
735ee42580 | ||
|
|
103ae81b8b | ||
|
|
8e351193e1 | ||
|
|
d57b9281a1 | ||
|
|
e07627377e | ||
|
|
8899f4b772 | ||
|
|
e7fd268927 | ||
|
|
c8fe3a4c43 | ||
|
|
19c2502c31 | ||
|
|
56dae4babd | ||
|
|
bc20d7527c | ||
|
|
3d325d4fe5 | ||
|
|
ba0141cfb1 | ||
|
|
d32c7b4056 | ||
|
|
63f064ba1c | ||
|
|
e5c9df31e4 | ||
|
|
c0a8e895f7 | ||
|
|
064ae44ecf | ||
|
|
005ba6e5ea | ||
|
|
9f6aba6cbd |
10
.github/ISSUE_TEMPLATE/ask-a-question.md
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
name: Ask a question
|
||||
about: Ask a question about mpv.net
|
||||
title: ''
|
||||
labels: question
|
||||
assignees: stax76
|
||||
|
||||
---
|
||||
|
||||
This template is meant for usage questions of mpv.net.
|
||||
27
.github/ISSUE_TEMPLATE/report-a-bug.md
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
name: Report a bug
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: stax76
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
20
.github/ISSUE_TEMPLATE/request-a-feature.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Request a feature
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: feature request
|
||||
assignees: stax76
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
67
Changelog.md
@@ -1,67 +0,0 @@
|
||||
### 4.3
|
||||
|
||||
- there was new bug in file association feature
|
||||
|
||||
### 4.2
|
||||
|
||||
- the help and layout in the config editor was improved
|
||||
- clipboard monitoring for URLs can be disabled in the settings
|
||||
- the context menu has a new feature: Open > Add files to playlist,
|
||||
it appends files to the playlist [(Default binding)](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt#L33)
|
||||
- a setting was added to force using a single mpv.net process instance
|
||||
|
||||
### 4.1
|
||||
|
||||
- drag & drop support for subtitles was added
|
||||
- libmpv was updated
|
||||
- command line support for stdin and URLs was added
|
||||
- there was a crash happening when the player is
|
||||
minimized in the taskbar
|
||||
|
||||
### 4.0
|
||||
|
||||
- on the start screen the mpv.NET icon is shown instead of the mpv icon,
|
||||
feedback and contributions regarding the icon are welcome! The paint.net
|
||||
pdn and png source is located [here](https://github.com/stax76/mpv.net/tree/master/img)
|
||||
- everytime only one file is opened the complete folder is loaded in the playlist
|
||||
- the info command (i key) shows the audio format
|
||||
- new options osd-font-size, sub-font, sub-font-size
|
||||
- new color options with dedicated GUI support: sub-color, sub-border-color, sub-back-color
|
||||
- the config editor no longer shows the command line switches
|
||||
- the github start page was greatly improved
|
||||
- the setup.ps1 PowerShell script was greatly improved in regard of error handling and readability
|
||||
- a [manual to mpv.net](Manual.md) was created
|
||||
|
||||
### 3.7
|
||||
|
||||
- new icon design, probably better then before but still too simple
|
||||
- the radio buttons in the config editor have now a Windows 10 like design,
|
||||
they are larger and use the Windows theme color
|
||||
|
||||
### 3.6.1
|
||||
|
||||
- there was a bug causing an exception if both the input editor and config editor
|
||||
is opened, as soon as one is opened, the other can't be opened
|
||||
|
||||
### 3.6
|
||||
|
||||
- playing files from rar archives caused an exception
|
||||
- there was a bug that caused underscores beeing removed from input like MBTN_LEFT_DBL
|
||||
- the search clear button in the input editor had a render issue in dark mode
|
||||
- new search feature added to search and play media files, requires
|
||||
[Everything](https://www.voidtools.com) to be installed. [Default Binding](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt#L29)
|
||||
|
||||
### 3.5
|
||||
|
||||
- when the main windows gets activated and the clipboard content starts with http
|
||||
mpv.net will ask to play the URL, previously this was restricted to YouTube URLs
|
||||
- Python script errors show line and column whenever it is supported by IronPython
|
||||
- if conf files exist in the startup directory mpv.net will use the startup
|
||||
directory as config directory instead of creating default conf files in appdata
|
||||
- renamed commands are handled now by migration code instead of being broken
|
||||
|
||||
### 3.4
|
||||
|
||||
- new feature added to manage file associations from within the app. It can be found in the menu at: Tools > Manage... [Default Binding](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt#L149)
|
||||
- new zip download option added
|
||||
- new x86 download option added
|
||||
21
LICENSE.txt
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017-2019 Frank Skare (stax76)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and ssociated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
831
Manual.md
@@ -1,831 +0,0 @@
|
||||
# mpv.net manual
|
||||
|
||||
## Table of contents
|
||||
|
||||
* [About mpv.net](#about-mpvnet)
|
||||
+ [Target Audience](#target-audience)
|
||||
* [Requirements](#requirements)
|
||||
* [Installation](#installation)
|
||||
+ [File Associations](#file-associations)
|
||||
* [Context Menu](#context-menu)
|
||||
+ [Open > Open Files](#open--open-files)
|
||||
+ [Open > Open URL](#open--open-url)
|
||||
+ [Open > Show media search](#open--show-media-search)
|
||||
+ [Open > Load external audio files](#open--load-external-audio-files)
|
||||
+ [Open > Load external subtitle files](#open--load-external-subtitle-files)
|
||||
+ [Play/Pause](#play-pause)
|
||||
+ [Stop](#stop)
|
||||
+ [Toggle Fullscreen](#toggle-fullscreen)
|
||||
+ [Navigate > Previous File](#navigate--previous-file)
|
||||
+ [Navigate > Next File](#navigate--next-file)
|
||||
+ [Navigate > Next Chapter](#navigate--next-chapter)
|
||||
+ [Navigate > Previous Chapter](#navigate--previous-chapter)
|
||||
+ [Navigate > Jump Next Frame](#navigate--jump-next-frame)
|
||||
+ [Navigate > Jump Previous Frame](#navigate--jump-previous-frame)
|
||||
+ [Navigate > Jump](#navigate--jump)
|
||||
+ [Pan & Scan > Increase Size](#pan--scan--increase-size)
|
||||
+ [Pan & Scan > Decrease Size](#pan--scan--decrease-size)
|
||||
+ [Pan & Scan > Move Left](#pan--scan--move-left)
|
||||
+ [Pan & Scan > Move Right](#pan--scan--move-right)
|
||||
+ [Pan & Scan > Move Up](#pan--scan--move-up)
|
||||
+ [Pan & Scan > Move Down](#pan--scan--move-down)
|
||||
+ [Pan & Scan > Decrease Height](#pan--scan--decrease-height)
|
||||
+ [Pan & Scan > Increase Height](#pan--scan--increase-height)
|
||||
+ [Pan & Scan > Reset](#pan--scan--reset)
|
||||
+ [Video > Decrease Contrast](#video--decrease-contrast)
|
||||
+ [Video > Increase Contrast](#video--increase-contrast)
|
||||
+ [Video > Decrease Brightness](#video--decrease-brightness)
|
||||
+ [Video > Increase Brightness](#video--increase-brightness)
|
||||
+ [Video > Decrease Gamma](#video--decrease-gamma)
|
||||
+ [Video > Increase Gamma](#video--increase-gamma)
|
||||
+ [Video > Decrease Saturation](#video--decrease-saturation)
|
||||
+ [Video > Increase Saturation](#video--increase-saturation)
|
||||
+ [Video > Take Screenshot](#video--take-screenshot)
|
||||
+ [Video > Toggle Deinterlace](#video--toggle-deinterlace)
|
||||
+ [Video > Cycle Aspect Ratio](#video--cycle-aspect-ratio)
|
||||
+ [Audio > Cycle/Next](#audio--cycle-next)
|
||||
+ [Audio > Delay +0.1](#audio--delay--01)
|
||||
+ [Audio > Delay -0.1](#audio--delay--01)
|
||||
+ [Subtitle > Cycle/Next](#subtitle--cycle-next)
|
||||
+ [Subtitle > Toggle Visibility](#subtitle--toggle-visibility)
|
||||
+ [Subtitle > Delay -0.1](#subtitle--delay--01)
|
||||
+ [Subtitle > Delay 0.1](#subtitle--delay-01)
|
||||
+ [Subtitle > Move Up](#subtitle--move-up)
|
||||
+ [Subtitle > Move Down](#subtitle--move-down)
|
||||
+ [Subtitle > Decrease Subtitle Font Size](#subtitle--decrease-subtitle-font-size)
|
||||
+ [Subtitle > Increase Subtitle Font Size](#subtitle--increase-subtitle-font-size)
|
||||
+ [Volume > Up](#volume--up)
|
||||
+ [Volume > Down](#volume--down)
|
||||
+ [Volume > Mute](#volume--mute)
|
||||
+ [Speed > -10%](#speed---10-)
|
||||
+ [Speed > 10%](#speed--10-)
|
||||
+ [Speed > Half](#speed--half)
|
||||
+ [Speed > Double](#speed--double)
|
||||
+ [Speed > Reset](#speed--reset)
|
||||
+ [Extensions > Rating > 0stars](#extensions--rating--0stars)
|
||||
+ [View > On Top > Enable](#view--on-top--enable)
|
||||
+ [View > On Top > Disable](#view--on-top--disable)
|
||||
+ [View > File Info](#view--file-info)
|
||||
+ [View > Show Statistics](#view--show-statistics)
|
||||
+ [View > Toggle Statistics](#view--toggle-statistics)
|
||||
+ [View > Toggle OSC Visibility](#view--toggle-osc-visibility)
|
||||
+ [View > Show Playlist](#view--show-playlist)
|
||||
+ [View > Show Audio/Video/Subtitle List](#view--show-audio-video-subtitle-list)
|
||||
+ [Settings > Show Config Editor](#settings--show-config-editor)
|
||||
+ [Settings > Show Input Editor](#settings--show-input-editor)
|
||||
+ [Settings > Open Config Folder](#settings--open-config-folder)
|
||||
+ [Tools > Command Palette](#tools--command-palette)
|
||||
+ [Tools > Show History](#tools--show-history)
|
||||
+ [Tools > Set/clear A-B loop points](#tools--set-clear-a-b-loop-points)
|
||||
+ [Tools > Toggle infinite file looping](#tools--toggle-infinite-file-looping)
|
||||
+ [Tools > Cycle Hardware Decoding](#tools--cycle-hardware-decoding)
|
||||
+ [Tools > Execute mpv command](#tools--execute-mpv-command)
|
||||
+ [Tools > Manage File Associations](#tools--manage-file-associations)
|
||||
+ [Help > Show mpv manual](#help--show-mpv-manual)
|
||||
+ [Help > Show mpv default keys](#help--show-mpv-default-keys)
|
||||
+ [Help > Show mpv.net default keys](#help--show-mpvnet-default-keys)
|
||||
+ [Help > Show mpv.net manual](#help--show-mpvnet-manual)
|
||||
+ [Help > About mpv.net](#help--about-mpvnet)
|
||||
+ [Exit](#exit)
|
||||
+ [Exit Watch Later](#exit-watch-later)
|
||||
* [Command Line Interface](#command-line-interface)
|
||||
* [Settings](#settings)
|
||||
|
||||
## About mpv.net
|
||||
|
||||
mpv.net is a media player for Windows. Similar like VLC mpv.net is not based on DirectShow like MPC, mpv.net is based on libmpv which in return is based on ffmpeg.
|
||||
|
||||
libmpv provides the majority of the features of the mpv media player, a fork of mplayer. mpv focuses on the usage of the command line interface, mpv.net retains the ability to be used from the command line and adds a simple and easy to use GUI on top of it.
|
||||
|
||||
mpv.net is meant to be a small single person project, it's designed to be mpv compatible, can use the same settings as mpv and offers almost all mpv features because they are all contained in libmpv, this means the official [mpv manual](https://mpv.io/manual/master/) fully applies to mpv.net.
|
||||
|
||||
### Target Audience
|
||||
|
||||
The target audience of mpv.net are Windows programmers and users that need something more advanced than common media players.
|
||||
|
||||
Furthermore mpv.net is well suited for Windows users who are interested to learn about the Linux operating system and portable apps, even though mpv.net self is not portable.
|
||||
|
||||
## Requirements
|
||||
|
||||
mpv.net is based on the .NET Framework and requires Windows 7 as minimum version of the Windows operating system. As of the writing of this manual the minimum required .NET Framework version is 4.7.2.
|
||||
|
||||
For optimal results a modern graphics card is recommended.
|
||||
|
||||
## Installation
|
||||
|
||||
mpv.net is available as setup and as portable download in the 7zip and zip archive format, to unpack the portable download 7zip can be used, it is available at www.7-zip.org.
|
||||
|
||||
If you are new to mpv.net the portable download is recommended, for regular mpv.net users the setup is typically more easy to use.
|
||||
|
||||
The x64 editions require more memory and have the advantage of decoders being typically first and better optimized for x64.
|
||||
|
||||
x86 should though still be well supported and work.
|
||||
|
||||
### File Associations
|
||||
|
||||
File Associations can be created using the setup or from within the apps context menu under 'Tools > Manage File Associations'.
|
||||
|
||||
Windows 10 prevents apps to register as the default app, to define the default video or audio player app in Windows 10 go to the Windows settings under 'Settings > Apps > Default apps' or shell execute 'ms-settings:defaultapps'.
|
||||
|
||||
It's also possible to change the default application using the Open With feature of the context menu in Windows File Explorer.
|
||||
|
||||
## Context Menu
|
||||
|
||||
The most important part of the user interface in mpv.net is the context menu, the menu can be customized as it is defined in the same file where the key bindings are defined.
|
||||
|
||||
### Open > Open Files
|
||||
|
||||
The Open Files menu entry is one way to open files in mpv.net, it supports multi selection.
|
||||
|
||||
Another way to open files is the command line, it is used by the Windows File Explorer if file associations exist.
|
||||
|
||||
A third way is to drag and drop files on the main window.
|
||||
|
||||
### Open > Open URL
|
||||
|
||||
The Open URL menu entry can be used to open URLs for example from YouTube.
|
||||
|
||||
mpv.net monitors the Windows clipboard and ask if URLs should be played in case it finds a URL in the clipboard.
|
||||
|
||||
### Open > Show media search
|
||||
|
||||
mpv.net supports system wide media searches using the Everything indexing service installed by the popular file search tool Everything (www.voidtools.com).
|
||||
|
||||
### Open > Load external audio files
|
||||
|
||||
Allows to load an external audio file. It's also possible to auto detect external audio files based on the file name, the option for this can be found in the settings under 'Settings > Show Config Editor > Audio > audio-file-auto'.
|
||||
|
||||
### Open > Load external subtitle files
|
||||
|
||||
Allows to load an external subtitle file. It's also possible to auto detect external subtitle files based on the file name, the option for this can be found in the settings under 'Settings > Show Config Editor > Subtitles > sub-auto'.
|
||||
|
||||
### Play/Pause
|
||||
|
||||
Play/Pause using the command:
|
||||
|
||||
`cycle pause`
|
||||
|
||||
[cycle command](https://mpv.io/manual/master/#command-interface-cycle-%3Cproperty%3E-[up|down])
|
||||
|
||||
[pause property](https://mpv.io/manual/master/#options-pause)
|
||||
|
||||
### Stop
|
||||
|
||||
Stops the player and unloads the playlist using the command:
|
||||
|
||||
`stop`
|
||||
|
||||
[stop command](https://mpv.io/manual/master/#command-interface-stop)
|
||||
|
||||
### Toggle Fullscreen
|
||||
|
||||
Toggles fullscreen using the command:
|
||||
|
||||
`cycle fullscreen`
|
||||
|
||||
[cycle command](https://mpv.io/manual/master/#command-interface-cycle-%3Cproperty%3E-[up|down])
|
||||
|
||||
[fullscreen property](https://mpv.io/manual/master/#options-fs)
|
||||
|
||||
### Navigate > Previous File
|
||||
|
||||
Navigates to the previous file in the playlist using the command:
|
||||
|
||||
`playlist-prev`
|
||||
|
||||
[playlist-prev command](https://mpv.io/manual/master/#command-interface-playlist-prev)
|
||||
|
||||
### Navigate > Next File
|
||||
|
||||
Navigates to the next file in the playlist using the command:
|
||||
|
||||
`playlist-next`
|
||||
|
||||
[playlist-next command](https://mpv.io/manual/master/#command-interface-playlist-next)
|
||||
|
||||
### Navigate > Next Chapter
|
||||
|
||||
Navigates to the next chapter using the command:
|
||||
|
||||
`add chapter 1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[chapter property](https://mpv.io/manual/master/#command-interface-chapter)
|
||||
|
||||
### Navigate > Previous Chapter
|
||||
|
||||
Navigates to the previous chapter using the command:
|
||||
|
||||
`add chapter -1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[chapter property](https://mpv.io/manual/master/#command-interface-chapter)
|
||||
|
||||
### Navigate > Jump Next Frame
|
||||
|
||||
Jumps to the next frame using the command:
|
||||
|
||||
`frame-step`
|
||||
|
||||
[frame-step command](https://mpv.io/manual/master/#command-interface-frame-step)
|
||||
|
||||
### Navigate > Jump Previous Frame
|
||||
|
||||
Jumps to the previous frame using the command:
|
||||
|
||||
`frame-back-step`
|
||||
|
||||
[frame-back-step command](https://mpv.io/manual/master/#command-interface-frame-back-step)
|
||||
|
||||
### Navigate > Jump
|
||||
|
||||
Seeking using the command:
|
||||
|
||||
`no-osd seek sec`
|
||||
|
||||
sec is the relative amount of seconds to jump, the no-osd prefix
|
||||
is used because mpv.net includes a script that shows the position
|
||||
when a seek operation is performed, the script uses a more simple
|
||||
time format.
|
||||
|
||||
[no-osd command prefix](https://mpv.io/manual/master/#command-interface-no-osd)
|
||||
|
||||
[seek command](https://mpv.io/manual/master/#command-interface-[relative|absolute|absolute-percent|relative-percent|exact|keyframes])
|
||||
|
||||
### Pan & Scan > Increase Size
|
||||
|
||||
Adds video zoom using the command:
|
||||
|
||||
`add video-zoom 0.1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[video-zoom property](https://mpv.io/manual/master/#options-video-zoom)
|
||||
|
||||
### Pan & Scan > Decrease Size
|
||||
|
||||
Adds negative video zoom using the command:
|
||||
|
||||
`add video-zoom -0.1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[video-zoom property](https://mpv.io/manual/master/#options-video-zoom)
|
||||
|
||||
### Pan & Scan > Move Left
|
||||
|
||||
`add video-pan-x -0.01`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[video-pan-x, video-pan-y property](https://mpv.io/manual/master/#options-video-pan-y)
|
||||
|
||||
### Pan & Scan > Move Right
|
||||
|
||||
`add video-pan-x 0.01`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[video-pan-x, video-pan-y property](https://mpv.io/manual/master/#options-video-pan-y)
|
||||
|
||||
### Pan & Scan > Move Up
|
||||
|
||||
`add video-pan-y -0.01`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[video-pan-x, video-pan-y property](https://mpv.io/manual/master/#options-video-pan-y)
|
||||
|
||||
### Pan & Scan > Move Down
|
||||
|
||||
`add video-pan-y 0.01`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[video-pan-x, video-pan-y property](https://mpv.io/manual/master/#options-video-pan-y)
|
||||
|
||||
### Pan & Scan > Decrease Height
|
||||
|
||||
`add panscan -0.1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[panscan property](https://mpv.io/manual/master/#options-panscan)
|
||||
|
||||
### Pan & Scan > Increase Height
|
||||
|
||||
`add panscan 0.1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[panscan property](https://mpv.io/manual/master/#options-panscan)
|
||||
|
||||
### Pan & Scan > Reset
|
||||
|
||||
Resets Pan & Scan, multiple commands in the same line are separated with semicolon.
|
||||
|
||||
`set video-zoom 0; set video-pan-x 0; set video-pan-y 0`
|
||||
|
||||
[video-zoom property](https://mpv.io/manual/master/#options-video-zoom)
|
||||
|
||||
[video-pan-x, video-pan-y property](https://mpv.io/manual/master/#options-video-pan-y)
|
||||
|
||||
### Video > Decrease Contrast
|
||||
|
||||
Decreases contrast with the following command:
|
||||
|
||||
`add contrast -1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[contrast property](https://mpv.io/manual/master/#options-contrast)
|
||||
|
||||
### Video > Increase Contrast
|
||||
|
||||
Increases contrast with the following command:
|
||||
|
||||
`add contrast 1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[contrast property](https://mpv.io/manual/master/#options-contrast)
|
||||
|
||||
### Video > Decrease Brightness
|
||||
|
||||
Decreases brightness using the following command:
|
||||
|
||||
`add brightness -1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[brightness property](https://mpv.io/manual/master/#options-brightness)
|
||||
|
||||
### Video > Increase Brightness
|
||||
|
||||
Increases brightness using the following command:
|
||||
|
||||
`add brightness 1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[brightness property](https://mpv.io/manual/master/#options-brightness)
|
||||
|
||||
### Video > Decrease Gamma
|
||||
|
||||
Decreases gamma using the following command:
|
||||
|
||||
`add gamma -1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[gamma property](https://mpv.io/manual/master/#options-gamma)
|
||||
|
||||
### Video > Increase Gamma
|
||||
|
||||
Increases gamma using the following command:
|
||||
|
||||
`add gamma 1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[gamma property](https://mpv.io/manual/master/#options-gamma)
|
||||
|
||||
### Video > Decrease Saturation
|
||||
|
||||
Decreases saturation using the following command:
|
||||
|
||||
`add saturation -1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[saturation property](https://mpv.io/manual/master/#options-saturation)
|
||||
|
||||
### Video > Increase Saturation
|
||||
|
||||
Increases saturation using the following command:
|
||||
|
||||
`add saturation 1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[saturation property](https://mpv.io/manual/master/#options-saturation)
|
||||
|
||||
### Video > Take Screenshot
|
||||
|
||||
`async screenshot`
|
||||
|
||||
[async command prefix](https://mpv.io/manual/master/#command-interface-async)
|
||||
|
||||
[screenshot command](https://mpv.io/manual/master/#command-interface-[subtitles|video|window|single|each-frame])
|
||||
|
||||
### Video > Toggle Deinterlace
|
||||
|
||||
Cycles the deinterlace property using the following command:
|
||||
|
||||
`cycle deinterlace`
|
||||
|
||||
[cycle command](https://mpv.io/manual/master/#command-interface-cycle-%3Cproperty%3E-[up|down])
|
||||
|
||||
[deinterlace property](https://mpv.io/manual/master/#options-deinterlace)
|
||||
|
||||
### Video > Cycle Aspect Ratio
|
||||
|
||||
Cycles the aspect ratio using the following command:
|
||||
|
||||
`cycle-values video-aspect "16:9" "4:3" "2.35:1" "-1"`
|
||||
|
||||
[cycle-values command](https://mpv.io/manual/master/#command-interface-cycle-values)
|
||||
|
||||
[video-aspect property](https://mpv.io/manual/master/#options-video-aspect)
|
||||
|
||||
### Audio > Cycle/Next
|
||||
|
||||
This uses a mpv.net command that shows better info then the mpv preset
|
||||
and also has the advantage of not showing no audio.
|
||||
|
||||
### Audio > Delay +0.1
|
||||
|
||||
Adds a audio delay using the following command:
|
||||
|
||||
`add audio-delay 0.1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[audio-delay property](https://mpv.io/manual/master/#options-audio-delay)
|
||||
|
||||
### Audio > Delay -0.1
|
||||
|
||||
Adds a negative audio delay using the following command:
|
||||
|
||||
`add audio-delay -0.1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[audio-delay property](https://mpv.io/manual/master/#options-audio-delay)
|
||||
|
||||
### Subtitle > Cycle/Next
|
||||
|
||||
Shows the next subtitle track using the following command:
|
||||
|
||||
`cycle sub`
|
||||
|
||||
[cycle command](https://mpv.io/manual/master/#command-interface-cycle-%3Cproperty%3E-[up|down])
|
||||
|
||||
[sub/sid property](https://mpv.io/manual/master/#options-sid)
|
||||
|
||||
### Subtitle > Toggle Visibility
|
||||
|
||||
Cycles the subtitle visibility using the following command:
|
||||
|
||||
`cycle sub-visibility`
|
||||
|
||||
[cycle command](https://mpv.io/manual/master/#command-interface-cycle-%3Cproperty%3E-[up|down])
|
||||
|
||||
[sub-visibility property](https://mpv.io/manual/master/#options-no-sub-visibility)
|
||||
|
||||
### Subtitle > Delay -0.1
|
||||
|
||||
Adds a negative subtitle delay using the following command:
|
||||
|
||||
`add sub-delay -0.1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[sub-delay property](https://mpv.io/manual/master/#options-sub-delay)
|
||||
|
||||
### Subtitle > Delay 0.1
|
||||
|
||||
Adds a positive subtitle delay using the following command:
|
||||
|
||||
`add sub-delay 0.1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[sub-delay property](https://mpv.io/manual/master/#options-sub-delay)
|
||||
|
||||
### Subtitle > Move Up
|
||||
|
||||
Moves the subtitle up using the following command:
|
||||
|
||||
`add sub-pos -1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[sub-pos property](https://mpv.io/manual/master/#options-sub-pos)
|
||||
|
||||
### Subtitle > Move Down
|
||||
|
||||
Moves the subtitle down using the following command:
|
||||
|
||||
`add sub-pos 1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[sub-pos property](https://mpv.io/manual/master/#options-sub-pos)
|
||||
|
||||
### Subtitle > Decrease Subtitle Font Size
|
||||
|
||||
Decreases the subtitle font size using the following command:
|
||||
|
||||
`add sub-scale -0.1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[sub-scale property](https://mpv.io/manual/master/#options-sub-scale)
|
||||
|
||||
### Subtitle > Increase Subtitle Font Size
|
||||
|
||||
Increases the subtitle font size using the following command:
|
||||
|
||||
`add sub-scale 0.1`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[sub-scale property](https://mpv.io/manual/master/#options-sub-scale)
|
||||
|
||||
### Volume > Up
|
||||
|
||||
Increases the volume using the following command:
|
||||
|
||||
`add volume 10`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[volume property](https://mpv.io/manual/master/#options-volume)
|
||||
|
||||
### Volume > Down
|
||||
|
||||
Decreases the volume using the following command:
|
||||
|
||||
`add volume -10`
|
||||
|
||||
[add command](https://mpv.io/manual/master/#command-interface-add-%3Cproperty%3E-[%3Cvalue%3E])
|
||||
|
||||
[volume property](https://mpv.io/manual/master/#options-volume)
|
||||
|
||||
### Volume > Mute
|
||||
|
||||
Cycles the mute property using the following command:
|
||||
|
||||
`cycle mute`
|
||||
|
||||
[cycle command](https://mpv.io/manual/master/#command-interface-cycle-%3Cproperty%3E-[up|down])
|
||||
|
||||
[mute property](https://mpv.io/manual/master/#options-mute)
|
||||
|
||||
### Speed > -10%
|
||||
|
||||
Decreases the speed by 10% using the following command:
|
||||
|
||||
`multiply speed 1/1.1`
|
||||
|
||||
[multiply command](https://mpv.io/manual/master/#command-interface-multiply-%3Cproperty%3E-%3Cfactor%3E)
|
||||
|
||||
[speed property](https://mpv.io/manual/master/#options-speed)
|
||||
|
||||
### Speed > 10%
|
||||
|
||||
Increases the speed by 10% using the following command:
|
||||
|
||||
`multiply speed 1.1`
|
||||
|
||||
[multiply command](https://mpv.io/manual/master/#command-interface-multiply-%3Cproperty%3E-%3Cfactor%3E)
|
||||
|
||||
[speed property](https://mpv.io/manual/master/#options-speed)
|
||||
|
||||
### Speed > Half
|
||||
|
||||
Halfs the speed using the following command:
|
||||
|
||||
`multiply speed 0.5`
|
||||
|
||||
[multiply command](https://mpv.io/manual/master/#command-interface-multiply-%3Cproperty%3E-%3Cfactor%3E)
|
||||
|
||||
[speed property](https://mpv.io/manual/master/#options-speed)
|
||||
|
||||
### Speed > Double
|
||||
|
||||
Doubles the speed using the following command:
|
||||
|
||||
`multiply speed 2`
|
||||
|
||||
[multiply command](https://mpv.io/manual/master/#command-interface-multiply-%3Cproperty%3E-%3Cfactor%3E)
|
||||
|
||||
[speed property](https://mpv.io/manual/master/#options-speed)
|
||||
|
||||
### Speed > Reset
|
||||
|
||||
Resets the speed using the following command:
|
||||
|
||||
`set speed 1`
|
||||
|
||||
[set command](https://mpv.io/manual/master/#command-interface-set-%3Cproperty%3E-%22%3Cvalue%3E%22)
|
||||
|
||||
[speed property](https://mpv.io/manual/master/#options-speed)
|
||||
|
||||
### Extensions > Rating > 0stars
|
||||
|
||||
A plugin the writes the rating to the filename.
|
||||
|
||||
### View > On Top > Enable
|
||||
|
||||
Forces the player to stay on top of other windows using the following command:
|
||||
|
||||
`set ontop yes`
|
||||
|
||||
[set command](https://mpv.io/manual/master/#command-interface-set-%3Cproperty%3E-%22%3Cvalue%3E%22)
|
||||
|
||||
[ontop property](https://mpv.io/manual/master/#options-ontop)
|
||||
|
||||
### View > On Top > Disable
|
||||
|
||||
Disables the player to stay on top of other windows using the following command:
|
||||
|
||||
`set ontop no`
|
||||
|
||||
[set command](https://mpv.io/manual/master/#command-interface-set-%3Cproperty%3E-%22%3Cvalue%3E%22)
|
||||
|
||||
[ontop property](https://mpv.io/manual/master/#options-ontop)
|
||||
|
||||
### View > File Info
|
||||
|
||||
Shows info using a mpv.net command about the current file, shows length, position, formats, size and filename.
|
||||
|
||||
### View > Show Statistics
|
||||
|
||||
Show statistics using the following command:
|
||||
|
||||
`script-binding stats/display-stats`
|
||||
|
||||
[script-binding command](https://mpv.io/manual/master/#command-interface-script-binding)
|
||||
|
||||
### View > Toggle Statistics
|
||||
|
||||
Toggles statistics using the following command:
|
||||
|
||||
`script-binding stats/display-stats-toggle`
|
||||
|
||||
[script-binding command](https://mpv.io/manual/master/#command-interface-script-binding)
|
||||
|
||||
### View > Toggle OSC Visibility
|
||||
|
||||
Toggles OSC Visibility using the following command:
|
||||
|
||||
`script-binding osc/visibility`
|
||||
|
||||
[script-binding command](https://mpv.io/manual/master/#command-interface-script-binding)
|
||||
|
||||
### View > Show Playlist
|
||||
|
||||
Shows the playlist for 5 seconds using the following command:
|
||||
|
||||
`show-text ${playlist} 5000`
|
||||
|
||||
[show-text command](https://mpv.io/manual/master/#command-interface-show-text)
|
||||
|
||||
### View > Show Audio/Video/Subtitle List
|
||||
|
||||
Shows the Audio/Video/Subtitle list for 5 seconds using the following command:
|
||||
|
||||
`show-text ${track-list} 5000`
|
||||
|
||||
[show-text command](https://mpv.io/manual/master/#command-interface-show-text)
|
||||
|
||||
### Settings > Show Config Editor
|
||||
|
||||
Shows mpv.net's config editor.
|
||||
|
||||
### Settings > Show Input Editor
|
||||
|
||||
Shows mpv.net's key binding editor.
|
||||
|
||||
### Settings > Open Config Folder
|
||||
|
||||
Opens the config folder which contains:
|
||||
|
||||
mpv.conf file containing mpv settings
|
||||
|
||||
mpvnet.conf file containing mpv.net settings
|
||||
|
||||
input.conf containing mpv key bindings
|
||||
|
||||
User scripts and user extensions
|
||||
|
||||
### Tools > Command Palette
|
||||
|
||||
Shows the command palette window which allows to find mpv.net commands, it shows the command's location in the context menu and the key shortcut.
|
||||
|
||||
### Tools > Show History
|
||||
|
||||
When enabled shows a file that contains the playback history containing the time and filename.
|
||||
|
||||
### Tools > Set/clear A-B loop points
|
||||
|
||||
Enables to set loop start and end points using the following command:
|
||||
|
||||
`ab-loop`
|
||||
|
||||
[ab-loop command](https://mpv.io/manual/master/#command-interface-ab-loop)
|
||||
|
||||
### Tools > Toggle infinite file looping
|
||||
|
||||
Loops the current file infinitely using the following command:
|
||||
|
||||
cycle-values loop-file "inf" "no"
|
||||
|
||||
[cycle-values command](https://mpv.io/manual/master/#command-interface-cycle-values)
|
||||
|
||||
[loop-file command](https://mpv.io/manual/master/#options-loop)
|
||||
|
||||
### Tools > Cycle Hardware Decoding
|
||||
|
||||
Cycles the hwdec property to enable/disable hardware decoding using the following command:
|
||||
|
||||
`cycle-values hwdec "auto" "no"`
|
||||
|
||||
[cycle-values command](https://mpv.io/manual/master/#command-interface-cycle-values)
|
||||
|
||||
[hwdec property](https://mpv.io/manual/master/#options-hwdec)
|
||||
|
||||
### Tools > Execute mpv command
|
||||
|
||||
Allows to execute mpv commands.
|
||||
|
||||
### Tools > Manage File Associations
|
||||
|
||||
Allows to manage file associations.
|
||||
|
||||
### Help > Show mpv manual
|
||||
|
||||
Shows the [mpv manual](https://mpv.io/manual/stable/).
|
||||
|
||||
### Help > Show mpv default keys
|
||||
|
||||
Shows the [mpv default keys](https://github.com/mpv-player/mpv/blob/master/etc/input.conf)
|
||||
|
||||
### Help > Show mpv.net default keys
|
||||
|
||||
Shows the [mpv.net default keys](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt)
|
||||
|
||||
Help > Show mpv.net web site
|
||||
|
||||
Shows the [mpv.net web site](https://mpv-net.github.io/mpv.net-web-site/)
|
||||
|
||||
### Help > Show mpv.net manual
|
||||
|
||||
Shows the [mpv.net manual](https://github.com/stax76/mpv.net/blob/master/Manual.md)
|
||||
|
||||
### Help > About mpv.net
|
||||
|
||||
Shows the mpv.net about dialog.
|
||||
|
||||
### Exit
|
||||
|
||||
Exits mpv.net using the following command:
|
||||
|
||||
`quit`
|
||||
|
||||
[quit command](https://mpv.io/manual/master/#command-interface-quit-[%3Ccode%3E])
|
||||
|
||||
### Exit Watch Later
|
||||
|
||||
Exits mpv.net and remembers the position in the file using the following command:
|
||||
|
||||
`quit-watch-later`
|
||||
|
||||
[quit-watch-later command](https://mpv.io/manual/master/#command-interface-quit-watch-later)
|
||||
|
||||
## Command Line Interface
|
||||
|
||||
mpvnet implements a basic CLI to set mpv commands.
|
||||
|
||||
Example:
|
||||
|
||||
mpvnet --mute=yes <file|URL>
|
||||
|
||||
## Settings
|
||||
|
||||
mpv.net is able to share the settings with mpv and mpv.net uses the same logic to decide from where the settings are loaded. The default location is:
|
||||
|
||||
```Text
|
||||
C:\Users\%username%\AppData\Roaming\mpv\mpv.conf
|
||||
```
|
||||
|
||||
If a directory named portable_config next to the mpvnet.exe exists, all config will be loaded from this directory only.
|
||||
|
||||
```Text
|
||||
<startup>\portable_config\mpv.conf
|
||||
```
|
||||
|
||||
In case there isn't any config folder mpv.net asks where to create it. If no mpv.conf file exists mpv.net generates it with the following defaults:
|
||||
|
||||
<https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpvConf.txt>
|
||||
|
||||
Config files located in the same directory as mpvnet.exe are loaded with lower priority. Some config files are loaded only once, which means that e.g. of 2 input.conf files located in two config directories, only the one from the directory with higher priority will be loaded.
|
||||
|
||||
The key bindings and the context menu definitions are stored in the input.conf file,
|
||||
if it's missing mpv.net generates it with the following defaults:
|
||||
|
||||
<https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt>
|
||||
250
README.md
@@ -1,225 +1,149 @@
|
||||

|
||||
|
||||
# 🎞 mpv.net
|
||||

|
||||
|
||||
mpv.net is a modern media player for Windows that works just like [mpv](https://mpv.io).
|
||||
    
|
||||
|
||||
#### Based on libmpv
|
||||
🎞 mpv.net
|
||||
==========
|
||||
|
||||
mpv.net is a modern media player for Windows based on the popular [mpv](https://mpv.io) player.
|
||||
|
||||
|
||||
#### Graphical User Interface
|
||||
|
||||
Modern GUI with customizable color themes.
|
||||
|
||||
mpv.net is based on libmpv which offers a straightforward C API that was designed from the ground up to make mpv usable as a library and facilitate easy integration into other applications. mpv is like vlc not based on DirectShow or Media Foundation.
|
||||
|
||||
#### Command Line Interface
|
||||
|
||||
mpv.net has the [CLI of mpv](https://mpv.io/manual/master/#options).
|
||||
mpv.net supports mpvs property based command line switches.
|
||||
|
||||
|
||||
#### High quality video output
|
||||
|
||||
libmpv has an OpenGL based video output that is capable of many features loved by videophiles, such as video scaling with popular high quality algorithms, color management, frame timing, interpolation, HDR, and more.
|
||||
Video output that is capable of many features loved by videophiles, such as video scaling with popular high quality algorithms, color management, frame timing, interpolation, HDR, and more.
|
||||
|
||||
|
||||
#### On Screen Controller
|
||||
|
||||
The OSC of libmpv offers play controls with a modern flat design. ([Screenshot](#main-window-screenshot))
|
||||
Play controls with a modern flat design.
|
||||
|
||||
|
||||
#### GPU video decoding
|
||||
|
||||
libmpv leverages the FFmpeg hwaccel APIs to support DXVA2 video decoding acceleration.
|
||||
Leverages the FFmpeg hwaccel APIs to support DXVA2 video decoding acceleration.
|
||||
|
||||
|
||||
#### Active development
|
||||
|
||||
mpv.net is under active development. Want a feature? Post a [patch](https://github.com/stax76/mpv.net/pulls) or [request it](https://github.com/stax76/mpv.net/issues)!
|
||||
mpv.net is under active development.
|
||||
|
||||
|
||||
#### Based on libmpv
|
||||
|
||||
mpv.net is based on libmpv which offers a straightforward C API that was designed from the ground up to make mpv usable as a library and facilitate easy integration into other applications. mpv is like VLC not based on DirectShow or Media Foundation.
|
||||
|
||||
|
||||
Table of contents
|
||||
-----------------
|
||||
|
||||
- [Features](#features)
|
||||
- [Screenshots](#screenshots)
|
||||
- [Manual](#manual)
|
||||
- [Context Menu](#context-menu)
|
||||
- [Settings](#settings)
|
||||
- [Scripting](#scripting)
|
||||
- [Add-ons](#add-ons)
|
||||
- [Architecture](#architecture)
|
||||
- [Support](#support)
|
||||
- [Links](#links)
|
||||
- [Changelog](#changelog)
|
||||
- [Download](#download)
|
||||
- [Manual](#manual)
|
||||
- [Screenshots](#screenshots)
|
||||
|
||||
### Features
|
||||
|
||||
- Customizable context menu defined in the same file as the key bindings ([Screenshot](#context-menu-screenshot), [Defaults](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt))
|
||||
- Searchable config dialog ([Screenshot](#config-editor-screenshot), [Defaults](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpvConf.txt))
|
||||
- Searchable input (key/mouse) binding editor ([Screenshot](#input-editor-screenshot), [Defaults](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt))
|
||||
- Searchable command palette to quickly launch commands and look for keys ([Screenshot](#command-palette-screenshot))
|
||||
- Modern UI with dark mode ([Screenshot](#config-editor-screenshot))
|
||||
- Addon/extension API for .NET languages
|
||||
- Scripting API for Python, C#, Lua, JavaScript and PowerShell ([wiki](https://github.com/stax76/mpv.net/wiki/Scripting))
|
||||
- mpv's OSC, IPC and conf files
|
||||
- [Command Line Interface](https://mpv.io/manual/master/#options)
|
||||
Features
|
||||
--------
|
||||
|
||||
- High degree of mpv compatibility, almost all mpv features are available
|
||||
- Customizable context menu defined in the same file as the key bindings
|
||||
- Config dialog
|
||||
- Shorcut key editor
|
||||
- Global hotkeys
|
||||
- Many features like the config editor and shortcut key editor are fully searchable
|
||||
- Configuration files that are easy to read and edit
|
||||
- Command palette to quickly find commands and keys
|
||||
- Modern graphical user interface with customizable color themes
|
||||
- Extension API for .NET languages (C#, VB.NET and F#)
|
||||
- Scripting API for C#, Lua, JavaScript and PowerShell
|
||||
- JSON IPC to control the player with a external programs
|
||||
- On Screen Controler (OSC, play control buttons) with modern flat design
|
||||
- Command Line Interface
|
||||
- Started from a terminal status and debug output is printed on the terminal
|
||||
- DXVA2 video decoding acceleration
|
||||
- OpenGL based video output capable of features loved by videophiles, such as video scaling with popular high quality algorithms, color management, frame timing, interpolation, HDR, and more
|
||||
- Search feature powered by [Everything](https://www.voidtools.com) to find and play media ([Screenshot](#media-search-screenshot))
|
||||
- Video output capable of features loved by videophiles, such as video scaling with popular high quality algorithms, color management, frame timing, interpolation, HDR, and more
|
||||
- File search feature powered by the popular search and index tool Everything
|
||||
- Browser extensions to start mpv.net from the browser
|
||||
- Fast seek performance
|
||||
- Fast startup performance
|
||||
- Usable as video player, audio player and image viewer with a wide range of supported formats
|
||||
- Built-in decoders, no external codecs have to be installed
|
||||
- Setup as x64 installer, portable and Chocolatey
|
||||
- Build-in media streaming (requires youtube-dl being installed)
|
||||
- File associations can be created by the setup and from the player
|
||||
- External audio and subtitle files can be loaded manually or automatically
|
||||
- Screenshot feature
|
||||
- File history feature to log time and filename
|
||||
- Watch later feature to save the position
|
||||
- Files can be enqueued from File Explorer
|
||||
- Update check and update routine
|
||||
|
||||
### Screenshots
|
||||
|
||||
#### Main Window Screenshot
|
||||
## [Support](docs/Manual.md#support)
|
||||
|
||||

|
||||
[Support section of the manual.](docs/Manual.md#support)
|
||||
|
||||
#### Context Menu Screenshot
|
||||
|
||||
Context menu defined in the input.conf file with dark mode support.
|
||||
## [Download](docs/Manual.md#download)
|
||||
|
||||

|
||||
[Download section of the manual.](docs/Manual.md#download)
|
||||
|
||||
#### Config Editor Screenshot
|
||||
|
||||
A searchable config editor as alternative to edit the mpv.conf file manually.
|
||||
## [Manual](docs/Manual.md)
|
||||
|
||||

|
||||
[The mpv.net documentation.](docs/Manual.md)
|
||||
|
||||
#### Input Editor Screenshot
|
||||
|
||||
A searchable key and mouse binding editor.
|
||||
Screenshots
|
||||
-----------
|
||||
|
||||

|
||||
#### Main Window
|
||||
|
||||
#### Command Palette Screenshot
|
||||

|
||||
|
||||
Forgot where a command in the menu is located or what shortcut key it has?
|
||||
Just press Ctrl+Shift+P and find it easily in the searchable command palette.
|
||||
|
||||

|
||||
#### Context Menu
|
||||
|
||||
#### Media Search Screenshot
|
||||
Context menu using dark mode.
|
||||
|
||||
Media search feature powered by [Everything](https://www.voidtools.com) to find and play media.
|
||||

|
||||
|
||||

|
||||
|
||||
### Manual
|
||||
#### Config Editor
|
||||
|
||||
[Manual](Manual.md)
|
||||
Searchable config editor as alternative to edit the conf file manually.
|
||||
|
||||
### Context Menu
|
||||

|
||||
|
||||
The context menu can be customized via input.conf file located in the config directory:
|
||||
|
||||
```Text
|
||||
C:\Users\%username%\AppData\Roaming\mpv\input.conf
|
||||
```
|
||||
#### Terminal
|
||||
|
||||
if it's missing mpv.net generates it with the following defaults:
|
||||
OSD console and status printed on the terminal.
|
||||
|
||||
<https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt>
|
||||

|
||||
|
||||
input.conf defines mpv's key and mouse bindings and mpv.net uses comments to define the context menu.
|
||||
|
||||
### Settings
|
||||
#### Input Editor
|
||||
|
||||
mpv.net is able to share the settings with mpv and mpv.net uses the same logic to decide from where the settings are loaded. The default location is:
|
||||
Searchable key and mouse binding editor.
|
||||
|
||||
```Text
|
||||
C:\Users\%username%\AppData\Roaming\mpv\mpv.conf
|
||||
```
|
||||

|
||||
|
||||
If a directory named portable_config next to the mpvnet.exe exists, all config will be loaded from this directory only.
|
||||
|
||||
```Text
|
||||
<startup>\portable_config\mpv.conf
|
||||
```
|
||||
#### Command Palette
|
||||
|
||||
In case there isn't any config folder mpv.net asks where to create it. If no mpv.conf file exists mpv.net generates it with the following defaults:
|
||||
Command Palette to find commands and shortcut keys easily.
|
||||
|
||||
<https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpvConf.txt>
|
||||
|
||||
Config files located in the same directory as mpvnet.exe are loaded with lower priority. Some config files are loaded only once, which means that e.g. of 2 input.conf files located in two config directories, only the one from the directory with higher priority will be loaded.
|
||||
|
||||
The key bindings and the context menu definitions are stored in the input.conf file,
|
||||
if it's missing mpv.net generates it with the following defaults:
|
||||
|
||||
<https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt>
|
||||
|
||||
mpv.net supports almost all mpv settings and features, [limitations are listed in the wiki](https://github.com/stax76/mpv.net/wiki/Limitations).
|
||||
|
||||
### Scripting
|
||||
|
||||
[Scripting wiki page](https://github.com/stax76/mpv.net/wiki/Scripting)
|
||||
|
||||
### Add-ons
|
||||
|
||||
[Add-on wiki page](https://github.com/stax76/mpv.net/wiki/Addons)
|
||||
|
||||
### Architecture
|
||||
|
||||
mpv.net is written in C# 7.0 and runs on the .NET framework 4.7 or higher.
|
||||
|
||||
The Add-on implementation is based on the [Managed Extensibility Framework](https://docs.microsoft.com/en-us/dotnet/framework/mef/).
|
||||
|
||||
There are no specific extension or scripting interfaces but instead everyting
|
||||
is accessible for .NET compatible languages (C#, VB.NET, F#, Python, PowerShell),
|
||||
this decision was made to keep the code simple and lightweight.
|
||||
|
||||
Python scripting is implemented with IronPython which uses Python 2.7.
|
||||
|
||||
The main/video window is WinForms based, all other windows are WPF based.
|
||||
|
||||
The config editor adds it's controls dynamically and uses TOML to define it's
|
||||
content, there are only two simple types, StringSetting and OptionSetting.
|
||||
|
||||
mpv.net was started 2017 and consists of about 6000 lines of code and markup.
|
||||
|
||||
IDE, Editor: Visual Studio, Visual Studio Code.
|
||||
|
||||
Due to mpv.net being my first WPF app and mpv.net never meant to be a large
|
||||
application best practices and design pattern are not always applied.
|
||||
|
||||
Third party components:
|
||||
|
||||
- [libmpv, the heard and soul of mpv.net](https://mpv.io/)
|
||||
- [MediaInfo, no media related project could do without](https://mediaarea.net/en/MediaInfo)
|
||||
- [Tommy, a single file TOML parser](https://github.com/dezhidki/Tommy)
|
||||
- [IronPython, bringing Python to dotnet](https://ironpython.net/)
|
||||
- [CS-Script, scripting with C#](http://www.csscript.net/)
|
||||
- [Everything, a blazing fast file search service](https://www.voidtools.com)
|
||||
|
||||
### Support
|
||||
|
||||
[Support thread in Doom9 forum](https://forum.doom9.org/showthread.php?t=174841)
|
||||
|
||||
[Support thread in VideoHelp forum](https://forum.videohelp.com/threads/392514-mpv-net-a-extendable-media-player-for-windows)
|
||||
|
||||
[Issue tracker to report bugs and request features](https://github.com/stax76/mpv.net/issues)
|
||||
|
||||
[frank.skare.de@gmail.com](mailto:frank.skare.de@gmail.com?Subject=mpv.net%20support)
|
||||
|
||||
### Links
|
||||
|
||||
mpv manual: <https://mpv.io/manual/master/>
|
||||
|
||||
mpv wiki: <https://github.com/mpv-player/mpv/wiki>
|
||||
|
||||
mpv.net wiki: <https://github.com/stax76/mpv.net/wiki>
|
||||
|
||||
mpv apps: <https://github.com/mpv-player/mpv/wiki/Applications-using-mpv>
|
||||
|
||||
mpv user scripts: <https://github.com/mpv-player/mpv/wiki/User-Scripts>
|
||||
|
||||
mpv default key bindings: <https://github.com/mpv-player/mpv/blob/master/etc/input.conf>
|
||||
|
||||
mpv.net default key bindings: <https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt>
|
||||
|
||||
mpv download: <https://mpv.io/installation/>
|
||||
|
||||
mpv.net download: <https://github.com/stax76/mpv.net/releases>
|
||||
|
||||
mpv bugs and requests: <https://mpv.io/bug-reports/>
|
||||
|
||||
mpv.net bugs and requests: <https://github.com/stax76/mpv.net/issues>
|
||||
|
||||
### Changelog
|
||||
|
||||
[Changelog](Changelog.md)
|
||||
|
||||
### Download
|
||||
|
||||
<https://github.com/stax76/mpv.net/releases>
|
||||

|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
Imports System.ComponentModel.Composition
|
||||
Imports System.IO
|
||||
Imports System.Windows.Forms
|
||||
|
||||
Imports mpvnet
|
||||
|
||||
Imports CSScriptLibrary
|
||||
|
||||
<Export(GetType(IAddon))>
|
||||
Public Class CSScriptAddon
|
||||
Implements IAddon
|
||||
|
||||
Sub New()
|
||||
Dim scriptFiles As New List(Of String)
|
||||
|
||||
If Directory.Exists(mp.ConfFolder + "scripts") Then
|
||||
scriptFiles.AddRange(Directory.GetFiles(mp.ConfFolder + "scripts", "*.cs"))
|
||||
End If
|
||||
|
||||
If Directory.Exists(Application.StartupPath + "\scripts") Then
|
||||
scriptFiles.AddRange(Directory.GetFiles(Application.StartupPath + "\scripts", "*.cs"))
|
||||
End If
|
||||
|
||||
If scriptFiles.Count = 0 Then Return
|
||||
CSScriptLibrary.CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom
|
||||
|
||||
For Each i In scriptFiles
|
||||
Try
|
||||
CSScriptLibrary.CSScript.Evaluator.LoadCode(File.ReadAllText(i))
|
||||
Catch ex As Exception
|
||||
Msg.ShowException(ex)
|
||||
End Try
|
||||
Next
|
||||
End Sub
|
||||
End Class
|
||||
@@ -1,166 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{71808A87-8B1C-4DF8-957C-D79C3B164CCA}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>CSScriptAddon</RootNamespace>
|
||||
<AssemblyName>CSScriptAddon</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MyType>Windows</MyType>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>..\mpv.net\bin\Addons\CSScriptAddon\</OutputPath>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<NoWarn>42105,42106,42107,42353,42354,42355</NoWarn>
|
||||
<WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\mpv.net\bin\Addons\CSScriptAddon\</OutputPath>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<NoWarn>42105,42106,42107,42353,42354,42355</NoWarn>
|
||||
<WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionExplicit>On</OptionExplicit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionCompare>Binary</OptionCompare>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionStrict>On</OptionStrict>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>..\..\mpv.net\bin\x86\Addons\CSScriptAddon\</OutputPath>
|
||||
<NoWarn>42105,42106,42107,42353,42354,42355</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>..\mpv.net\bin\x86\Addons\CSScriptAddon\</OutputPath>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>42105,42106,42107,42353,42354,42355</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>..\..\mpv.net\bin\x64\Addons\CSScriptAddon\</OutputPath>
|
||||
<NoWarn>42105,42106,42107,42353,42354,42355</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>..\mpv.net\bin\x64\Addons\CSScriptAddon\</OutputPath>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>42105,42106,42107,42353,42354,42355</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="CSScriptLibrary, Version=3.27.5.0, Culture=neutral, PublicKeyToken=70fcc3d18c749033, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>.\CSScriptLibrary.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Import Include="Microsoft.VisualBasic" />
|
||||
<Import Include="System" />
|
||||
<Import Include="System.Collections" />
|
||||
<Import Include="System.Collections.Generic" />
|
||||
<Import Include="System.Data" />
|
||||
<Import Include="System.Diagnostics" />
|
||||
<Import Include="System.Linq" />
|
||||
<Import Include="System.Xml.Linq" />
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CSScriptAddon.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Resources.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Settings.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
|
||||
<CustomToolNamespace>My.Resources</CustomToolNamespace>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="My Project\Application.myapp">
|
||||
<Generator>MyApplicationCodeGenerator</Generator>
|
||||
<LastGenOutput>Application.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="My Project\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<CustomToolNamespace>My</CustomToolNamespace>
|
||||
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="CSScriptLibrary.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\mpv.net\mpv.net.csproj">
|
||||
<Project>{1751f378-8edf-4b62-be6d-304c7c287089}</Project>
|
||||
<Name>mpv.net</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
</Project>
|
||||
@@ -1,13 +0,0 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.42000
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<MySubMain>false</MySubMain>
|
||||
<SingleInstance>false</SingleInstance>
|
||||
<ShutdownMode>0</ShutdownMode>
|
||||
<EnableVisualStyles>true</EnableVisualStyles>
|
||||
<AuthenticationMode>0</AuthenticationMode>
|
||||
<ApplicationType>1</ApplicationType>
|
||||
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
|
||||
</MyApplicationData>
|
||||
@@ -1,35 +0,0 @@
|
||||
Imports System
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' General Information about an assembly is controlled through the following
|
||||
' set of attributes. Change these attribute values to modify the information
|
||||
' associated with an assembly.
|
||||
|
||||
' Review the values of the assembly attributes
|
||||
|
||||
<Assembly: AssemblyTitle("CSScriptAddon")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("")>
|
||||
<Assembly: AssemblyProduct("CSScriptAddon")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2019")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
'The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
<Assembly: Guid("4a748201-3948-497d-b156-7d172a332bd6")>
|
||||
|
||||
' Version information for an assembly consists of the following four values:
|
||||
'
|
||||
' Major Version
|
||||
' Minor Version
|
||||
' Build Number
|
||||
' Revision
|
||||
'
|
||||
' 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("1.0.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
@@ -1,63 +0,0 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.42000
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace My.Resources
|
||||
|
||||
'This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
'class via a tool like ResGen or Visual Studio.
|
||||
'To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
'with the /str option, or rebuild your VS project.
|
||||
'''<summary>
|
||||
''' A strongly-typed resource class, for looking up localized strings, etc.
|
||||
'''</summary>
|
||||
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0"), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
|
||||
Friend Module Resources
|
||||
|
||||
Private resourceMan As Global.System.Resources.ResourceManager
|
||||
|
||||
Private resourceCulture As Global.System.Globalization.CultureInfo
|
||||
|
||||
'''<summary>
|
||||
''' Returns the cached ResourceManager instance used by this class.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
|
||||
Get
|
||||
If Object.ReferenceEquals(resourceMan, Nothing) Then
|
||||
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("CSScriptAddon.Resources", GetType(Resources).Assembly)
|
||||
resourceMan = temp
|
||||
End If
|
||||
Return resourceMan
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' Overrides the current thread's CurrentUICulture property for all
|
||||
''' resource lookups using this strongly typed resource class.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend Property Culture() As Global.System.Globalization.CultureInfo
|
||||
Get
|
||||
Return resourceCulture
|
||||
End Get
|
||||
Set
|
||||
resourceCulture = value
|
||||
End Set
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
@@ -1,117 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
73
addons/CSScriptAddon/My Project/Settings.Designer.vb
generated
@@ -1,73 +0,0 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.42000
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
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
|
||||
|
||||
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
|
||||
|
||||
#Region "My.Settings Auto-Save Functionality"
|
||||
#If _MyType = "WindowsForms" Then
|
||||
Private Shared addedHandler As Boolean
|
||||
|
||||
Private Shared addedHandlerLockObject As New Object
|
||||
|
||||
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
|
||||
If My.Application.SaveMySettingsOnExit Then
|
||||
My.Settings.Save()
|
||||
End If
|
||||
End Sub
|
||||
#End If
|
||||
#End Region
|
||||
|
||||
Public Shared ReadOnly Property [Default]() As MySettings
|
||||
Get
|
||||
|
||||
#If _MyType = "WindowsForms" Then
|
||||
If Not addedHandler Then
|
||||
SyncLock addedHandlerLockObject
|
||||
If Not addedHandler Then
|
||||
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
|
||||
addedHandler = True
|
||||
End If
|
||||
End SyncLock
|
||||
End If
|
||||
#End If
|
||||
Return defaultInstance
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
|
||||
Friend Module MySettingsProperty
|
||||
|
||||
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
|
||||
Friend ReadOnly Property Settings() As Global.CSScriptAddon.My.MySettings
|
||||
Get
|
||||
Return Global.CSScriptAddon.My.MySettings.Default
|
||||
End Get
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
@@ -1,58 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using mpvnet;
|
||||
|
||||
namespace RatingAddon
|
||||
{
|
||||
[Export(typeof(IAddon))]
|
||||
public class RatingAddon : IAddon
|
||||
{
|
||||
Dictionary<string, int> Dic = new Dictionary<string, int>();
|
||||
|
||||
public RatingAddon()
|
||||
{
|
||||
mp.ClientMessage += mpv_ClientMessage;
|
||||
mp.Shutdown += mpv_Shutdown;
|
||||
}
|
||||
|
||||
void mpv_Shutdown()
|
||||
{
|
||||
foreach (var i in Dic)
|
||||
{
|
||||
string filepath = i.Key;
|
||||
int rating = i.Value;
|
||||
|
||||
if (String.IsNullOrEmpty(filepath) || ! File.Exists(filepath))
|
||||
return;
|
||||
|
||||
string basename = Path.GetFileNameWithoutExtension(filepath);
|
||||
|
||||
for (int x = 0; x < 6; x++)
|
||||
if (basename.Contains(" (" + x.ToString() + "stars)"))
|
||||
basename = basename.Replace(" (" + x.ToString() + "stars)", "");
|
||||
|
||||
basename += $" ({rating}stars)";
|
||||
string newPath = Path.Combine(Path.GetDirectoryName(filepath), basename + Path.GetExtension(filepath));
|
||||
|
||||
if (filepath.ToLower() != newPath.ToLower())
|
||||
File.Move(filepath, newPath);
|
||||
|
||||
File.SetLastWriteTime(newPath, DateTime.Now);
|
||||
}
|
||||
}
|
||||
|
||||
void mpv_ClientMessage(string[] args)
|
||||
{
|
||||
int rating;
|
||||
|
||||
if (args?.Length != 2 || args[0] != "rate-file" || ! int.TryParse(args[1], out rating))
|
||||
return;
|
||||
|
||||
Dic[mp.get_property_string("path")] = rating;
|
||||
mp.commandv("show-text", $"Rating: {rating}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{55C88710-539D-4402-84C8-31694841C731}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>RatingAddon</RootNamespace>
|
||||
<AssemblyName>RatingAddon</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\mpv.net\bin\Addons\RatingAddon\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\mpv.net\bin\Addons\RatingAddon\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\mpv.net\bin\x86\Addons\RatingAddon\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>..\mpv.net\bin\x86\Addons\RatingAddon\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\mpv.net\bin\x64\Addons\RatingAddon\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>..\mpv.net\bin\x64\Addons\RatingAddon\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="RatingAddon.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\mpv.net\mpv.net.csproj">
|
||||
<Project>{1751f378-8edf-4b62-be6d-304c7c287089}</Project>
|
||||
<Name>mpv.net</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("TestAddon")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TestAddon")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("06f854b0-00f9-4b53-94d9-0be65a7c55d8")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// 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("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -1,27 +0,0 @@
|
||||
using System.ComponentModel.Composition;
|
||||
|
||||
using mpvnet;
|
||||
|
||||
namespace TestAddon
|
||||
{
|
||||
[Export(typeof(IAddon))]
|
||||
public class TestAddon : IAddon
|
||||
{
|
||||
// do some init work in constructor
|
||||
public TestAddon()
|
||||
{
|
||||
// Observe changes of the fullscreen property.
|
||||
// You can find a list of available mpv properties
|
||||
// in mpv.net's wiki on github or use mpv --list-properties.
|
||||
// You can test properties in mpv.net in the menu at:
|
||||
// Tools > Execute mpv command
|
||||
// where you can enter: show-text ${fullscreen}
|
||||
mp.observe_property_bool("fullscreen", OnFullscreenChange);
|
||||
}
|
||||
|
||||
void OnFullscreenChange(bool val)
|
||||
{
|
||||
mp.commandv("show-text", "fullscreen: " + val.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
645
docs/Changelog.md
Normal file
@@ -0,0 +1,645 @@
|
||||
|
||||
5.4.9.0 (2021-05-29)
|
||||
====================
|
||||
|
||||
- `window-scale 1` does not work correctly in mpv,
|
||||
so I've removed support for it and added my own implementation:
|
||||
`script-message mpv.net window-scale`.
|
||||
- The CS-Script library was replaced with my own C# scripting implementation.
|
||||
- If a player window border is near to a screen border and the window size
|
||||
changes, the player windows sticks to that near screen border location.
|
||||
Furthermore the `remember-window-position` option remembers a near screen
|
||||
border position instead of remembering the window center position.
|
||||
- Multi monitor fix using different DPI values.
|
||||
- `start-size` option has new options, see config editor and manual.
|
||||
- Improved `script-message mpv.net cycle-audio` OSD info.
|
||||
- The logic for finding the config directory has changed, see manual.
|
||||
- The dotnet script and extension host was a little redesigned, this breaks
|
||||
backward compatibility unfortunately, but I can help fixing existing
|
||||
open source code however. Example scripts and extensions were updated.
|
||||
- Fix console not working due to incorrect mpv.conf value generated
|
||||
(script-opts=console-scale=0).
|
||||
- Settings are stored in the file settings.xml now instead of the Registry.
|
||||
- Video rotation support added.
|
||||
- After using the config editor it's no longer necessary to restart mpv.net.
|
||||
- Improved input editor theming.
|
||||
|
||||
|
||||
5.4.8.8 Beta (2021-05-09)
|
||||
=========================
|
||||
|
||||
- Improved window scaling.
|
||||
- Title property implementation.
|
||||
- Command palette shows commands without assigned menu item.
|
||||
- The code from the included JavaScript file was ported into the core
|
||||
player because JavaScript is currently broken in the builds of shinshiro.
|
||||
- New option `--command=<input command>`, can be used in combination
|
||||
with `process-instance=single` to control mpv.net via command line,
|
||||
for instance to create global hotkeys with AutoHotkey.
|
||||
- New global hotkey feature added using the file global-input.conf.
|
||||
- The global-media-keys option was removed because global-input.conf
|
||||
can be used instead.
|
||||
- MediaInfo 21.3
|
||||
- libmpv shinchiro 2021-04-04
|
||||
|
||||
|
||||
5.4.8.7 Beta (2021-03-09)
|
||||
=========================
|
||||
|
||||
- History feature can be configured to ingore defined strings:
|
||||
script-opt = history-discard=value1;value2
|
||||
- Web stream audio and subtitle track selection.
|
||||
- On Windows 10 1903 and later the default code page was changed to UTF-8.
|
||||
- Support of --version command.
|
||||
- File associations and auto-load-folder can be customized with
|
||||
video-file-extensions, audio-file-extensions and image-file-extensions.
|
||||
- Fix menu not showing key '&'.
|
||||
|
||||
|
||||
5.4.8.6 Beta (2020-12-24)
|
||||
=========================
|
||||
|
||||
- Santa hat shown in december. (#216)
|
||||
- Filename not being always shown in title bar. (#214)
|
||||
- Improved OSD message when cycling audio.
|
||||
- DVD audio and subtitle track selection.
|
||||
- Input keylist can be shown on the command-line with --input-keylist
|
||||
- Profiles can be shown on the command-line with --profile=help
|
||||
- Decoders can be shown on the command-line with --ad=help and --vd=help
|
||||
- Decoders can be shown in the menu under: View > Show Decoders
|
||||
- Demuxers can be shown in the menu under: View > Show Demuxers
|
||||
- Audio devices can be shown in the menu under: View > Show Audio Devices
|
||||
- Audio devices can be shown on the command-line with --audio-device=help
|
||||
- Protocols can be shown in the menu under: View > Show Protocols
|
||||
- Allow mpv.net to start from different startup locations
|
||||
without showing the setup dialog. (#218)
|
||||
- libmpv updated to shinshiro 2020-12-20
|
||||
|
||||
|
||||
5.4.8.5 Beta
|
||||
============
|
||||
|
||||
- Load AviSynth DLL from environment variable AviSynthDLL
|
||||
in order to support AviSynth portable mode.
|
||||
- New option global-media-keys (next, previous, play/pause, stop).
|
||||
- Redesigned PowerShell based setup and setup dialog, it was done
|
||||
because of a bug and upcoming chocolately and winget integration.
|
||||
- Redesigned auto update using different file name, using zip instead
|
||||
of 7zip format now, 7zip distribution will shortly get dropped.
|
||||
- Whenever there is a new startup location, the setup dialog is shown.
|
||||
- libmpv updated to shinshiro 2020-12-06
|
||||
- youtube-dl is no longer included, users have to install it
|
||||
on their own (put it in the startup or a PATH folder).
|
||||
|
||||
|
||||
5.4.8.4 Beta
|
||||
============
|
||||
|
||||
- Blu-rays with dozens of titles showed all titles in the menu
|
||||
which was difficult to choose and extremely slow.
|
||||
- Blu-ray folder paths are auto detected when received
|
||||
from drag & drop and command-line.
|
||||
- Cycle audio was not working for Blu-ray.
|
||||
- Message asking if image is BD or DVD in case image is < 10 GB.
|
||||
|
||||
|
||||
5.4.8.3 Beta
|
||||
============
|
||||
|
||||
- Support Wheel_Left and Wheel_Right. (arnesacnussem)
|
||||
- Default screen was changed from primary to OS default to start
|
||||
from the same screen where the File Explorer window is located.
|
||||
- When mpv.net was started maximized and next was invoked then the
|
||||
window state was changed to normal instead of staying maximized.
|
||||
|
||||
|
||||
5.4.8.2 Beta
|
||||
============
|
||||
|
||||
- CLI --shuffle issue fix.
|
||||
- ISO image files can be opened like any other files, files smaller
|
||||
than 10 GB are handled as DVD and larger as BluRay.
|
||||
- Menu support for BluRay title, audio and subtitle selection.
|
||||
- Property input-key-list can be shown with: View > Show Keys
|
||||
- youtube-dl 2020.06.16.1
|
||||
- libmpv 2020-06-21 shinchiro
|
||||
|
||||
|
||||
5.4.8.1 Beta
|
||||
============
|
||||
|
||||
- fix stdin support
|
||||
|
||||
|
||||
5.4.8.0
|
||||
=======
|
||||
|
||||
- fix learn window of input editor (much work)
|
||||
- fix black one pixel bar on right side
|
||||
- fix beep sound when closed from taskbar
|
||||
|
||||
|
||||
5.4.7.4 Beta (not yet released)
|
||||
============
|
||||
|
||||
- the media key issue should now be fixed!
|
||||
- libmpv and youtube-dl update
|
||||
|
||||
|
||||
5.4.7.3 Beta
|
||||
============
|
||||
|
||||
- new setting media-keys added, can be found in the config editor in the input tab.
|
||||
|
||||
|
||||
5.4.7.2 Beta
|
||||
============
|
||||
|
||||
- another attempt to fix a app command issue. WM_APPCOMMAND (mpv calls this media keys)
|
||||
based input is no longer directly passed to mpv but rather handled in mpv.net directly
|
||||
translating the native commands to mpv keys and sent via keypress input command to mpv
|
||||
- another attempt to fix a crash caused by powershell 5.1 not being installed
|
||||
|
||||
|
||||
5.4.7.1 Beta
|
||||
============
|
||||
|
||||
- log error fix, mpv.net does now ignore all log messages because libmpv already
|
||||
prints the log messages to the the terminal
|
||||
- the release script now also outputs x86 beta versions so x86 users can test betas
|
||||
|
||||
|
||||
5.4.7.0
|
||||
=======
|
||||
|
||||
- log error fix
|
||||
- workaround to support AviSynth portable (ffmpeg blocks loading AviSynth from path env var)
|
||||
- attempt to fix not reproducible volume input issue
|
||||
- attempt to fix exception caused by powershell being not available on Win 7
|
||||
|
||||
|
||||
5.4.6.0
|
||||
=======
|
||||
|
||||
- youtube-dl update
|
||||
- auto update routine fix
|
||||
|
||||
|
||||
5.4.5.1 Beta
|
||||
============
|
||||
|
||||
- extensions no longer need to end with *Extension.dll but rather
|
||||
the file name and the directory name must be identical
|
||||
- text encoding exception fix
|
||||
- the PowerShell script host is more feature complete, easier to use
|
||||
and more efficient, there were however many PowerShell and C# breaking
|
||||
changes requrired to make the core more robust and efficient
|
||||
- Python 2 script host removed, Python 3 support is planned for summer
|
||||
|
||||
|
||||
5.4.5.0
|
||||
=======
|
||||
|
||||
stable release, no changes since the last beta
|
||||
|
||||
|
||||
5.4.4.6 Beta
|
||||
============
|
||||
|
||||
- using start-size=video the window size was not remembered
|
||||
after fullscreen mode was left.
|
||||
- using start-size=video the window can now use the entire
|
||||
working area using autofit-larger=100
|
||||
|
||||
|
||||
5.4.4.5 Beta
|
||||
============
|
||||
|
||||
- overhaul of the [webpage](README.md) and the [manual](Manual.md).
|
||||
- change that possibly could fix a multimedia keyboard volume issue.
|
||||
|
||||
|
||||
5.4.4.4 Beta
|
||||
============
|
||||
|
||||
- with `border=no` the OSC top bar window buttons min, max and close are fully supported.
|
||||
- anamorphic videos are shown without black bars, the window is resized according to the ascpect ratio.
|
||||
- PowerShell 5.1 was made optional.
|
||||
- full implementation for `window-minimized` and `window-maximized`,
|
||||
scripts that depend on this like pause-when-minimize.lua are now fully supported.
|
||||
- fix cycling from maximized to fullscreen and back.
|
||||
|
||||
|
||||
5.4.4.3 Beta
|
||||
============
|
||||
|
||||
- update MediaInfo 20.03
|
||||
- update libmpv 2020-04-12, it supports vpy playback, read manual or ask in forum
|
||||
- mpv property `window-maximized` support added, cycling it from input.conf
|
||||
is not recommended, use native Windows shortcuts Win+Up, Win+Down
|
||||
- the mpv.net `start-size` option supports `always` to always remember the window height
|
||||
- if the window was maximized before fullscreen was entered, it's now set to
|
||||
maximized after fullscreen was left
|
||||
- with `border=no` the OSC did not auto hide after the mouse curser left the window
|
||||
- the script that modified the seek OSD was removed, it still can be found in the mpv wiki
|
||||
- certain videos were showed with black bars
|
||||
|
||||
|
||||
### 5.4.4.2
|
||||
|
||||
- update: libmpv shinchiro 0.32.0-258-g281f5c63c1
|
||||
- update: youtube-dl
|
||||
|
||||
- new: d3d11va-zero-copy setting added to conf editor
|
||||
- new: hdr-compute-peak setting added to conf editor
|
||||
- new: flag cli switches support now `--no-flag` in addition to `--flag=no`
|
||||
https://mpv.io/manual/master/#usage
|
||||
- new: cli switches can also start with single `-` instead of double `--`
|
||||
https://mpv.io/manual/master/#legacy-option-syntax
|
||||
- new: PowerShell script host was completely rewritten, events can be assigned
|
||||
by using `Register-ObjectEvent`, the scripting wiki page was updated
|
||||
https://github.com/stax76/mpv.net/wiki/Scripting#powershell
|
||||
- new: Context Menu > View > Show Profiles
|
||||
https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt#L147
|
||||
- new: Context Menu > View > Show Properties
|
||||
https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt#L148
|
||||
- new: Context Menu > View > Show Commands
|
||||
https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt#L149
|
||||
- new: config editor tab is now remembered
|
||||
- new: osd-duration setting added to config editor and default mpv.conf
|
||||
- new: external console replaced with internal console, in case mpv.conf is missing it's
|
||||
generated with correct Hight DPI font size scale settings.
|
||||
`script-opts=console-scale=<dpiscale>`
|
||||
https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt#L150
|
||||
https://mpv.io/manual/master/#console
|
||||
- new: blue color in dark theme is now less intense
|
||||
https://github.com/stax76/mpv.net/blob/master/Manual.md#color-theme
|
||||
- new: menu item 'View > Show Progress' (p key) to show progress bar
|
||||
https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt#L146
|
||||
- new: `script-message mpv.net playlist-first`, unlike mpv does not
|
||||
restart if the first file is already active
|
||||
https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt#L44
|
||||
- new: if mpv.net is started from the terminal and an error happens then the error
|
||||
is printed to the terminal instead of shown with a message box
|
||||
- fix: update routine did only work when mpv.net was located in 'Program Files'
|
||||
- fix: fatal errors were ignored and only seen in the terminal, now a message box is shown
|
||||
- fix: when start-size=video was used then enlarging or shrinking the window size was broken
|
||||
|
||||
### 5.4.4.0
|
||||
|
||||
- new: forecolors in the dark theme are slightly darker now
|
||||
- new: readme/website and manual were improved
|
||||
- new: source code includes now the release script to build the archives and setup files
|
||||
- new: the history feature now uses the full path
|
||||
- new: install via Scoop and Chocolatey added to readme/website (Restia666Ashdoll)
|
||||
- new: update check, it must be enabled first in the conf editor under General
|
||||
- new: update feature, requires PowerShell 5 and curl,
|
||||
an up to date Windows 10 system has both included.
|
||||
Main menu (input.conf) must be reset or updated manually ([defaults](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt))
|
||||
|
||||
- update: libmpv shinchiro 2019-11-10
|
||||
|
||||
- fix: often the OSC was shown when fullscreen was entered
|
||||
or on app startup, this is now suppressed
|
||||
- fix: the file association routine uses no longer 'Play with mpv.net' for the
|
||||
default open verb caption because it doesn't support multi selection,
|
||||
it shows now only Open, the manual explains how to get multi selection
|
||||
in File Explorer, read about it [here](https://github.com/stax76/mpv.net/blob/master/Manual.md#open-with)
|
||||
- fix: x86 builds had an older version included because
|
||||
of a misconfiguration in the solution file
|
||||
|
||||
### 5.4.3.0
|
||||
|
||||
- new: the color themes can now be customized ([manual](https://github.com/stax76/mpv.net/blob/master/Manual.md#color-theme))
|
||||
- new: three new sections were added to the [manual](https://github.com/stax76/mpv.net/blob/master/Manual.md):
|
||||
1. [Color Theme](https://github.com/stax76/mpv.net/blob/master/Manual.md#color-theme)
|
||||
2. [Hidden and secret features](https://github.com/stax76/mpv.net/blob/master/Manual.md#hidden-and-secret-features)
|
||||
3. [External Tools](https://github.com/stax76/mpv.net/blob/master/Manual.md#external-tools)
|
||||
|
||||
- fix: window restore from maximized and from minimized was broken
|
||||
- fix: it's possible to multi select files in File Explorer and press
|
||||
enter to open the files, this did however only work when the
|
||||
auto load folder feature was disabled or the shift key was
|
||||
pressed (blocks auto load folder). Now it should also work
|
||||
without shift key and with auto load folder being enabled
|
||||
|
||||
- update: libmpv shinchiro 2019-10-27
|
||||
- update: youtube-dl 2019-10-31
|
||||
|
||||
### 5.4.2.1 Beta
|
||||
|
||||
- pressing shift key suppresses auto-load-folder
|
||||
- switch --queue added, this will not clear the playlist but append
|
||||
and it will suppress auto-load-folder. To get a 'Add to mpv.net playlist'
|
||||
context menu item in explorer with multi selection support use my
|
||||
[Open with++](https://github.com/stax76/OpenWithPlusPlus#add-to-mpvnet-playlist) shell extension, as far as I know multi selection
|
||||
can not be done using the Registry but only via shell extension
|
||||
- window-size mpv property support added ([default bindings](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt#L137))
|
||||
- the config editor keeps profiles and comments in mpv.conf intact!
|
||||
- the options in the config editor are better organized
|
||||
|
||||
### 5.4.2
|
||||
|
||||
- new: the [scripting wiki page](https://github.com/stax76/mpv.net/wiki/Scripting#powershell) was improved
|
||||
- new: Toggle Shuffle has been added to the menu defaults
|
||||
- new: for URLs the media title is shown in the title bar and in the info command
|
||||
instead of displaying the URL, mpv.conf defaults were changed to use
|
||||
[protocol.https] osd-playing-msg = '${media-title}'
|
||||
|
||||
- fix: on the very first start volume was set to 0 and mute was set to yes
|
||||
- fix: there was a sound when closed from taskbar
|
||||
- fix: the log feature was not working
|
||||
- fix: clipboard monitoring removed because it was causing to many issues
|
||||
- fix: restore resulted in collapsed window when maximized = yes was used
|
||||
|
||||
- update: libmpv shinchiro 2019-10-06
|
||||
- update: youtube-dl 2019-10-01
|
||||
|
||||
### 5.4.1.1
|
||||
|
||||
- a issue with the taskbar-progress feature was fixed
|
||||
- improved PowerShell scrip host
|
||||
|
||||
### 5.4.1
|
||||
|
||||
- fix ArgumentOutOfRangeException
|
||||
|
||||
### 5.4
|
||||
|
||||
- added taskbar-progress implementation
|
||||
- added new setting to start with maximized window
|
||||
- long file paths work now even if not enabled by the OS
|
||||
- fixed history being written even when history file wasn't created prior
|
||||
- libmpv updated to shinchiro 2019-08-31
|
||||
|
||||
### 5.3
|
||||
|
||||
- added new feature: Open > Open DVD/Blu-ray Drive/Folder...
|
||||
- the default of remember-volume has been set to yes
|
||||
- scale, cscale, dscale defaults have been set to spline36,
|
||||
profile=gpu-hq is not used in the defaults because it starts very slow
|
||||
- new menu items have been added to navigate to the first and
|
||||
last playlist position, key bindings: Home, End
|
||||
- new config setting recent-count added, amount of menu items
|
||||
shown under 'Open > Recent'
|
||||
- in the config dialog the description for keep-open was corrected
|
||||
because unlike mpv, mpv.net will never terminate automatically
|
||||
- there was a rare occasion where the mpv.net logo wasn't shown
|
||||
- fix excessive memory usage using `osd-scale-by-window = no`
|
||||
- mpv setting osd-scale-by-window added to config dialog
|
||||
|
||||
### 5.2.1
|
||||
|
||||
- fixed race condition causing various features to fail
|
||||
|
||||
### 5.2
|
||||
|
||||
- bug fix for single-instance not working with unicode filenames
|
||||
- bug fix for logo not shown on start
|
||||
- osd-visibility.js script was removed because the OSC uses too much memory
|
||||
- youtube-dl was updated
|
||||
- libmpv was updated to shinchiro 2019-08-04
|
||||
- in case mpv.net was started from a terminal it sets now the mpv property input-terminal to yes,
|
||||
this means mpv.net will now receive and handle input keys from the terminal
|
||||
- certain command-line properties didn't work (input-terminal, terminal, input-file,
|
||||
config, config-dir, input-conf, load-scripts, script, scripts, player-operation-mode)
|
||||
- the about dialog shows now the mpv version and build date
|
||||
- the dialog that asks for a config folder has now a cancel option
|
||||
|
||||
### 5.1
|
||||
|
||||
- many [wiki pages](https://github.com/stax76/mpv.net/wiki) were improved
|
||||
- the logo/icon had a very small cosmetic change
|
||||
- the help in the context menu was improved,
|
||||
for quick access consider the command palette (F1 key)
|
||||
- config options specific to mpv.net are now available from the command-line
|
||||
- the input editor no longer has known limitations, 'alt gr' and ctrl+alt are working now
|
||||
- the help in the input editor was simplified and the filter logic was improved
|
||||
- fixed issue in file associations causing mpv.net not to appear in OS default apps
|
||||
- 'Tools > Manage File Associations' was replaced by 'Tools > OS Setup',
|
||||
it has now a feature to add and remove mpv.net to and from the Path
|
||||
environment variable and the OS default apps settings can be opened (Win 10 only)
|
||||
- startup folder and config folder being identical was causing a critical issue
|
||||
as mpv.net was loading extensions twice and scripts four times, now identical
|
||||
folders are no longer permitted
|
||||
- error messages are shown when unknown scripts and extensions are found in the startup folder
|
||||
because user scripts and extensions are supposed to be located in the config folder instead
|
||||
- changing from maximized to fullscreen did not work
|
||||
- the search field in the config editor was not always remembered
|
||||
- new setting remember-volume added, saves volume and mute on exit
|
||||
and restores it on start.
|
||||
- it's now enforced that mpv properties on the command-line and in
|
||||
the mpv.conf config file are lowercase, if not a error is shown
|
||||
- gpu-api vulkan was not working if media files were opened via
|
||||
command-line (that included Explorer)
|
||||
- new setting minimum-aspect-ratio added, minimum aspect ratio for the window,
|
||||
this was previously hard coded to 1.3
|
||||
- new setting auto-load-folder added, for single files automatically load
|
||||
the entire directory into the playlist, previously this was forced,
|
||||
now it can be disabled
|
||||
- new setting themed-menu added, follow theme color in context menu,
|
||||
default: no. UI related settings have now a separate UI tab in the config editor
|
||||
|
||||
### 5.0
|
||||
|
||||
- [changed icon design](https://github.com/stax76/mpv.net/blob/master/img/mpvnet.png)
|
||||
- libmpv was updated to shinchiro 2019-07-14
|
||||
- new or improved config editor settings: screenshot-directory,
|
||||
screenshot-format, screenshot-tag-colorspace, screenshot-high-bit-depth,
|
||||
screenshot-jpeg-source-chroma, screenshot-template, screenshot-jpeg-quality,
|
||||
screenshot-png-compression, screenshot-png-filter
|
||||
- mpv.conf preview feature added to config editor, it previews the mpv.conf content
|
||||
- in the entire project the term addon was replaced with the term extension,
|
||||
unfortunately this will break user extensions. The reason for this drastic
|
||||
change is that there exist too many different terms, addons, addins,
|
||||
extensions, modules, packages etc.. mpv.net follows Google Chrome as the worlds
|
||||
most popular extendable app, Chrome uses the term Extension.
|
||||
- a thread synchronization bug was fixed, the shutdown thread was aborted
|
||||
if it was running more than 3 seconds, this caused the rating extension
|
||||
to fail if it was waiting for a drive to wake up
|
||||
- a new JavaScript was included to show the playlist with a smaller font size,
|
||||
the script is located at startup/scripts
|
||||
- terminal support added using mpvnet.com !
|
||||
- script engine performance and error handling was improved
|
||||
- the [scripting wiki page](https://github.com/stax76/mpv.net/wiki/Scripting) was improved
|
||||
- the C# scripting host extension was converted from VB to C# because it's not
|
||||
only used for hosting but I also use it now to code and debug script code
|
||||
- there was a copy paste bug in the file association feature resulting in keys
|
||||
from mpv being overwritten instead of using mpv.net keys. Thanks to floppyD!
|
||||
- there was a exception fixed that happened opening rar files
|
||||
- instead of using the OS theme color there are now default colors
|
||||
for dark-color and light-color
|
||||
|
||||
### 4.7.7
|
||||
|
||||
- on Win 7 the theme color was hardcoded to DarkSlateGrey because
|
||||
WPF was returning a bad color on Win 7, this was fixed by reading
|
||||
the theme color from the Registry on Win 7. If the theme color
|
||||
is identical to the background color it's corrected
|
||||
- dark-color setting was added to overwrite the OS theme color used in dark mode,
|
||||
find the setting on the General tab
|
||||
- light-color setting was added to overwrite the OS theme color used in non dark mode,
|
||||
find the setting on the General tab
|
||||
- various changes regarding input handling, multi media keys and
|
||||
mouse forward/backward were successfully tested
|
||||
- it's now possible to use a custom folder as config folder,
|
||||
A TaskDialog shows five options: 1. appdata mpv.net, 2. appdata mpv (shared with mpv),
|
||||
3. portable_config, 4. startup, 5. custom
|
||||
- slightly increased startup performance, start-threshold setting added.
|
||||
Threshold in milliseconds to wait for libmpv returning the video resolution
|
||||
before the window is shown, otherwise default dimensions are used as defined
|
||||
by autofit and start-size. Default: 1500
|
||||
- autofit-smaller setting added. Minimum window height in percent. Default: 40%
|
||||
- autofit-larger setting added. Maximum window height in percent. Default: 75%
|
||||
|
||||
### 4.7.3
|
||||
|
||||
- fix cursor showing load activity on startup
|
||||
- added file size and type to info command using audio files
|
||||
- added image format support to the info command, to file
|
||||
association management, to folder loading, to Everything
|
||||
- readme/github have a updated features and architecture section
|
||||
|
||||
### 4.7.1
|
||||
|
||||
- few layout problems were fixed, autosize for instance did not work
|
||||
|
||||
### 4.7
|
||||
|
||||
- remember-height was replaced with start-size, when start-size is set
|
||||
to video the main video starts directly with the native video size,
|
||||
before it was starting with the autofit size first and was only
|
||||
afterwards resized to the native video size
|
||||
- on exit the window location can be saved with remember-position
|
||||
- in the learn window of the input editor underscores were stripped
|
||||
because they have a special meaning in WPF labels
|
||||
- fix for keys/input not working for MBTN_LEFT_DBL, MBTN_BACK, MBTN_FORWARD
|
||||
- in the learn window of the input editor support was added for
|
||||
mouse left, mouse left double, mouse mid, mouse forward, mouse back
|
||||
- libmpv was updated to shinchiro 2019-07-07
|
||||
- when border is none it wasn't possible to minimize the window from
|
||||
the task bar because this is the WinForms default behavier. This
|
||||
was fixed by calling Spy++ to the rescue and adding WS_MINIMIZEBOX
|
||||
in CreateParams
|
||||
|
||||
### 4.6
|
||||
|
||||
- fix for middle mouse button not working
|
||||
- fix of logo overlay using a huge amount of memory (thx for the [ghacks article](https://www.ghacks.net/2019/07/05/a-look-at-mpv-net-a-mpv-frontend-with-everything-integration/))
|
||||
- fix config dialog showing a message about app restart without reason
|
||||
- when multiple files are selected in File Explorer and enter is
|
||||
pressed, the files are opened as selected, the order is random though
|
||||
because Explorer starts multiple mpv.net processes concurrently
|
||||
- libmpv was updated to shinchiro 2019-06-30
|
||||
- the [mpv.conf defaults](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpv.conf.txt) were changed to show a larger OSC
|
||||
- in case a file is opened that has a aspect ratio smaller then 1.2 then
|
||||
the window size will use a aspect ratio of 1.8
|
||||
- new JavaScript script osc-visibility.js included in the distribution
|
||||
under startup\scripts. It sets the OSC to be always on for audio files
|
||||
and auto for non audio files
|
||||
|
||||
### 4.5
|
||||
|
||||
- opening a URL manually no longer uses a input box but uses the clipboard directly
|
||||
- the manifest was missing the company attribute which caused
|
||||
mpv.net not appearing in the 'Open with' menu of the File Explorer,
|
||||
thanks to 44vince44 for pointing this out!!!
|
||||
- new Python and C# script examples were added to the wiki and the scripting and
|
||||
extension documentation was improved
|
||||
- invalid command-line arguments were ignored, now an error message is shown
|
||||
- a description on how to start mpv.net from Google Chrome was added to the
|
||||
manual, it's useful to play videos from sites like YouTube, find the
|
||||
description [here](https://github.com/stax76/mpv.net/blob/master/Manual.md#chrome-extension)
|
||||
- new config setting remember-height added to remember the window height,
|
||||
otherwise the video's native resolution is used
|
||||
- support for protocols other then http added
|
||||
|
||||
### 4.4
|
||||
|
||||
- clipboard-monitoring was replaced by url-whitelist:
|
||||
Keyword whitelist to monitor the clipboard for URLs to play.
|
||||
Default: tube vimeo ard zdf
|
||||
- some settings like colors didn't work because enclosing quotes were missing
|
||||
- when single process queue is used the folder is no longer loaded
|
||||
- the playlist is never cleared whenever the control key is down but
|
||||
files and URLs are appended instead
|
||||
- powershell script hosting bugs were fixed and a new powershell example script
|
||||
was added to the [scripting wiki page](https://github.com/stax76/mpv.net/wiki/Scripting#powershell)
|
||||
- the menu entry for the command palette was renamed to 'Show All Commands' and
|
||||
the default key binding was changed to F1 which is also the default in VS Code
|
||||
- the default key binding of the Everything media search was changed to F3
|
||||
- support for the mpv property 'border' was added to the config editor
|
||||
to show/hide the window decoration (titlebar, border). A toggle menu item and
|
||||
key binding (b) was added as well ([Default Binding](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt#L135))
|
||||
|
||||
### 4.3.1
|
||||
|
||||
- there was a old bug setting the screen property
|
||||
|
||||
### 4.3
|
||||
|
||||
- there was new bug in file association feature
|
||||
|
||||
### 4.2
|
||||
|
||||
- the help and layout in the config editor was improved
|
||||
- clipboard monitoring for URLs can be disabled in the settings
|
||||
- the context menu has a new feature: Open > Add files to playlist,
|
||||
it appends files to the playlist [(Default binding)](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt#L33)
|
||||
- a setting was added to force using a single mpv.net process instance
|
||||
|
||||
### 4.1
|
||||
|
||||
- drag & drop support for subtitles was added
|
||||
- libmpv was updated
|
||||
- command-line support for stdin and URLs was added
|
||||
- there was a crash happening when the player is
|
||||
minimized in the taskbar
|
||||
|
||||
### 4.0
|
||||
|
||||
- on the start screen the mpv.NET icon is shown instead of the mpv icon,
|
||||
feedback and contributions regarding the icon are welcome! The paint.net
|
||||
pdn and png source is located [here](https://github.com/stax76/mpv.net/tree/master/img)
|
||||
- everytime only one file is opened the complete folder is loaded in the playlist
|
||||
- the info command (i key) shows the audio format
|
||||
- new options osd-font-size, sub-font, sub-font-size
|
||||
- new color options with dedicated GUI support: sub-color, sub-border-color, sub-back-color
|
||||
- the config editor no longer shows the command-line switches
|
||||
- the github start page was greatly improved
|
||||
- the setup.ps1 PowerShell script was greatly improved in regard of error handling and readability
|
||||
- a [manual to mpv.net](Manual.md) was created
|
||||
|
||||
### 3.7
|
||||
|
||||
- new icon design, probably better then before but still too simple
|
||||
- the radio buttons in the config editor have now a Windows 10 like design,
|
||||
they are larger and use the Windows theme color
|
||||
|
||||
### 3.6.1
|
||||
|
||||
- there was a bug causing an exception if both the input editor and config editor
|
||||
is opened, as soon as one is opened, the other can't be opened
|
||||
|
||||
### 3.6
|
||||
|
||||
- playing files from rar archives caused an exception
|
||||
- there was a bug that caused underscores beeing removed from input like MBTN_LEFT_DBL
|
||||
- the search clear button in the input editor had a render issue in dark mode
|
||||
- new search feature added to search and play media files, requires
|
||||
[Everything](https://www.voidtools.com) to be installed. [Default Binding](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt#L29)
|
||||
|
||||
### 3.5
|
||||
|
||||
- when the main windows gets activated and the clipboard content starts with http
|
||||
mpv.net will ask to play the URL, previously this was restricted to YouTube URLs
|
||||
- Python script errors show line and column whenever it is supported by IronPython
|
||||
- if conf files exist in the startup directory mpv.net will use the startup
|
||||
directory as config directory instead of creating default conf files in appdata
|
||||
- renamed commands are handled now by migration code instead of being broken
|
||||
|
||||
### 3.4
|
||||
|
||||
- new feature added to manage file associations from within the app. It can be found in the menu at: Tools > Manage... [Default Binding](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt#L149)
|
||||
- new zip download option added
|
||||
- new x86 download option added
|
||||
24
docs/License.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2017-2021 mpv.net/mpv/mplayer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and ssociated documentation
|
||||
files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
1401
docs/Manual.md
Normal file
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 212 KiB After Width: | Height: | Size: 212 KiB |
|
Before Width: | Height: | Size: 214 KiB After Width: | Height: | Size: 214 KiB |
BIN
docs/img/Main.png
Normal file
|
After Width: | Height: | Size: 2.5 MiB |
BIN
docs/img/MediaSearch.png
Normal file
|
After Width: | Height: | Size: 628 KiB |
BIN
docs/img/Menu.jpg
Normal file
|
After Width: | Height: | Size: 603 KiB |
BIN
docs/img/Terminal.png
Normal file
|
After Width: | Height: | Size: 2.2 MiB |
BIN
docs/img/mpvnet-santa.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
docs/img/mpvnet.ico
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
docs/img/mpvnet.pdn
Normal file
BIN
docs/img/mpvnet.png
Normal file
|
After Width: | Height: | Size: 8.2 KiB |
BIN
img/Main.png
|
Before Width: | Height: | Size: 5.8 MiB |
|
Before Width: | Height: | Size: 125 KiB |
BIN
img/Menu.png
|
Before Width: | Height: | Size: 1.3 MiB |
BIN
img/mpvnet.pdn
BIN
img/mpvnet.png
|
Before Width: | Height: | Size: 6.7 KiB |
79
mpv.net.sln
@@ -1,79 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.28729.10
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mpv.net", "mpv.net\mpv.net.csproj", "{1751F378-8EDF-4B62-BE6D-304C7C287089}"
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CSScriptAddon", "addons\CSScriptAddon\CSScriptAddon.vbproj", "{71808A87-8B1C-4DF8-957C-D79C3B164CCA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RatingAddon", "addons\RatingAddon\RatingAddon.csproj", "{55C88710-539D-4402-84C8-31694841C731}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAddon", "addons\TestAddon\TestAddon.csproj", "{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x64.Build.0 = Debug|x64
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x86.Build.0 = Debug|x86
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x64.ActiveCfg = Release|x64
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x64.Build.0 = Release|x64
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x86.ActiveCfg = Release|x86
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x86.Build.0 = Release|x86
|
||||
{71808A87-8B1C-4DF8-957C-D79C3B164CCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{71808A87-8B1C-4DF8-957C-D79C3B164CCA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{71808A87-8B1C-4DF8-957C-D79C3B164CCA}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{71808A87-8B1C-4DF8-957C-D79C3B164CCA}.Debug|x64.Build.0 = Debug|x64
|
||||
{71808A87-8B1C-4DF8-957C-D79C3B164CCA}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{71808A87-8B1C-4DF8-957C-D79C3B164CCA}.Debug|x86.Build.0 = Debug|x86
|
||||
{71808A87-8B1C-4DF8-957C-D79C3B164CCA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{71808A87-8B1C-4DF8-957C-D79C3B164CCA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{71808A87-8B1C-4DF8-957C-D79C3B164CCA}.Release|x64.ActiveCfg = Release|x64
|
||||
{71808A87-8B1C-4DF8-957C-D79C3B164CCA}.Release|x64.Build.0 = Release|x64
|
||||
{71808A87-8B1C-4DF8-957C-D79C3B164CCA}.Release|x86.ActiveCfg = Release|x86
|
||||
{71808A87-8B1C-4DF8-957C-D79C3B164CCA}.Release|x86.Build.0 = Release|x86
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x64.Build.0 = Debug|x64
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x86.Build.0 = Debug|x86
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x64.ActiveCfg = Release|x64
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x64.Build.0 = Release|x64
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x86.ActiveCfg = Release|x86
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x86.Build.0 = Release|x86
|
||||
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Debug|x64.Build.0 = Debug|x64
|
||||
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Debug|x86.Build.0 = Debug|x86
|
||||
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Release|x64.Build.0 = Release|Any CPU
|
||||
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8DE9E796-619E-44B8-9576-F4DE028701BF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,13 +0,0 @@
|
||||
<UserControl x:Class="Controls.SearchTextBoxUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid x:Name="SearchTextBoxUserControl1" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">
|
||||
<TextBlock x:Name="HintTextBlock" Margin="5,2" Text="Find a setting" Foreground="LightSteelBlue" VerticalAlignment="Center" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" />
|
||||
<TextBox Name="SearchTextBox" Height="25" Padding="1,2,0,0" BorderThickness="2" Background="Transparent" TextChanged="SearchTextBox_TextChanged" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" CaretBrush="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" />
|
||||
<Button x:Name="SearchClearButton" Background="Transparent" HorizontalAlignment="Right" Margin="2,0,4,0" FontSize="10" Width="17" Height="17" Visibility="Hidden" Click="SearchClearButton_Click" FontFamily="Marlett" Foreground="{Binding Path=Foreground2, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">r</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,28 +0,0 @@
|
||||
<UserControl x:Name="OptionSettingControl1" x:Class="DynamicGUI.OptionSettingControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DynamicGUI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid Margin="20,0">
|
||||
<StackPanel>
|
||||
<TextBox x:Name="TitleTextBox" FontSize="24" Margin="0,10" BorderThickness="0" IsReadOnly="True" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"></TextBox>
|
||||
<ItemsControl x:Name="ItemsControl">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<WrapPanel Orientation="Vertical">
|
||||
<RadioButton x:Name="RadioButton" VerticalContentAlignment="Center" IsChecked="{Binding Checked}" GroupName="{Binding OptionSetting.Name}" Content="{Binding Text}" FontSize="16" FontWeight="Normal" VerticalAlignment="Top" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"></RadioButton>
|
||||
<TextBox x:Name="ItemHelpTextBox" TextWrapping="WrapWithOverflow" Text="{Binding Help}" Visibility="{Binding Visibility}" Margin="10,0,0,0" BorderThickness="0" IsReadOnly="True" Padding="7,0,0,0" MinHeight="0" Foreground="{Binding Path=Foreground2, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"></TextBox>
|
||||
</WrapPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<TextBox x:Name="HelpTextBox" TextWrapping="WrapWithOverflow" BorderThickness="0" IsReadOnly="True" Margin="0,10,0,0" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"></TextBox>
|
||||
<TextBlock x:Name="LinkTextBlock" Margin="0,10">
|
||||
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,27 +0,0 @@
|
||||
<UserControl x:Name="StringSettingControl1" x:Class="DynamicGUI.StringSettingControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DynamicGUI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
<Grid Margin="20,0">
|
||||
<StackPanel>
|
||||
<TextBox x:Name="TitleTextBox" FontSize="24" Margin="0,10" BorderThickness="0" IsReadOnly="True" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"></TextBox>
|
||||
<Grid Margin="0,0,0,10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox x:Name="ValueTextBox" Text="{Binding Path=Text, ElementName=StringSettingControl1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="150" HorizontalAlignment="Left" Height="20" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" TextChanged="ValueTextBox_TextChanged"/>
|
||||
<Button x:Name="Button" Height="20" Grid.Column="1" Visibility="{Binding Path=Text, ElementName=StringSettingControl1}" Margin="5,0,0,0" Width="20" Click="Button_Click">...</Button>
|
||||
</Grid>
|
||||
<TextBox x:Name="HelpTextBox" TextWrapping="WrapWithOverflow" BorderThickness="0" IsReadOnly="True" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"></TextBox>
|
||||
<TextBlock x:Name="LinkTextBlock" Margin="0,10">
|
||||
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.ComponentModel.Composition.Hosting;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class Addon
|
||||
{
|
||||
[ImportMany]
|
||||
public IEnumerable<IAddon> Addons = null;
|
||||
|
||||
readonly CompositionContainer CompositionContainer;
|
||||
|
||||
public Addon()
|
||||
{
|
||||
try
|
||||
{
|
||||
AggregateCatalog catalog = new AggregateCatalog();
|
||||
|
||||
string dir = Application.StartupPath + "\\Addons";
|
||||
|
||||
if (Directory.Exists(dir))
|
||||
foreach (string i in Directory.GetDirectories(dir))
|
||||
catalog.Catalogs.Add(new DirectoryCatalog(i, "*Addon.dll"));
|
||||
|
||||
dir = mp.ConfFolder + "\\Addons";
|
||||
|
||||
if (Directory.Exists(dir))
|
||||
foreach (string i in Directory.GetDirectories(dir))
|
||||
catalog.Catalogs.Add(new DirectoryCatalog(i, "*Addon.dll"));
|
||||
|
||||
if (catalog.Catalogs.Count > 0)
|
||||
{
|
||||
CompositionContainer = new CompositionContainer(catalog);
|
||||
CompositionContainer.ComposeParts(this);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Msg.ShowException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IAddon
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,288 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Interop;
|
||||
|
||||
using VB = Microsoft.VisualBasic;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class Command
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public Action<string[]> Action { get; set; }
|
||||
|
||||
static List<Command> commands;
|
||||
|
||||
public static List<Command> Commands
|
||||
{
|
||||
get
|
||||
{
|
||||
if (commands == null)
|
||||
{
|
||||
commands = new List<Command>();
|
||||
Type type = typeof(Command);
|
||||
MethodInfo[] methods = type.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
|
||||
|
||||
foreach (MethodInfo i in methods)
|
||||
{
|
||||
ParameterInfo[] parameters = i.GetParameters();
|
||||
|
||||
if (parameters == null || parameters.Length != 1 || parameters[0].ParameterType != typeof(string[]))
|
||||
continue;
|
||||
|
||||
Command cmd = new Command() { Name = i.Name.Replace("_","-"), Action = (Action<string[]>)i.CreateDelegate(typeof(Action<string[]>)) };
|
||||
commands.Add(cmd);
|
||||
}
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
}
|
||||
|
||||
public static void open_files(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
using (var d = new OpenFileDialog() { Multiselect = true })
|
||||
if (d.ShowDialog() == DialogResult.OK)
|
||||
mp.Load(d.FileNames);
|
||||
}));
|
||||
}
|
||||
|
||||
public static void open_conf_folder(string[] args)
|
||||
{
|
||||
Process.Start(mp.ConfFolder);
|
||||
}
|
||||
|
||||
public static void show_input_editor(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
InputWindow w = new InputWindow();
|
||||
new WindowInteropHelper(w).Owner = MainForm.Instance.Handle;
|
||||
w.ShowDialog();
|
||||
}));
|
||||
}
|
||||
|
||||
public static void show_conf_editor(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
ConfWindow w = new ConfWindow();
|
||||
new WindowInteropHelper(w).Owner = MainForm.Instance.Handle;
|
||||
w.ShowDialog();
|
||||
}));
|
||||
}
|
||||
|
||||
public static void show_about(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
AboutWindow w = new AboutWindow();
|
||||
new WindowInteropHelper(w).Owner = MainForm.Instance.Handle;
|
||||
w.ShowDialog();
|
||||
}));
|
||||
}
|
||||
|
||||
public static void show_command_palette(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
var w = new CommandPaletteWindow();
|
||||
new WindowInteropHelper(w).Owner = MainForm.Instance.Handle;
|
||||
w.ShowDialog();
|
||||
}));
|
||||
}
|
||||
|
||||
public static void show_media_search(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
var w = new EverythingWindow();
|
||||
new WindowInteropHelper(w).Owner = MainForm.Instance.Handle;
|
||||
w.ShowDialog();
|
||||
}));
|
||||
}
|
||||
|
||||
public static void show_history(string[] args)
|
||||
{
|
||||
var fp = mp.ConfFolder + "history.txt";
|
||||
|
||||
if (File.Exists(fp))
|
||||
Process.Start(fp);
|
||||
else
|
||||
if (Msg.ShowQuestion("Create history.txt file in config folder?",
|
||||
"mpv.net will write the date, time and filename of opened files to it.") == MsgResult.OK)
|
||||
File.WriteAllText(fp, "");
|
||||
}
|
||||
|
||||
public static void shell_execute(string[] args) => Process.Start(args[0]);
|
||||
|
||||
public static void show_info(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
string performer, title, album, genre, date, duration, text = "";
|
||||
long fileSize = 0;
|
||||
string path = mp.get_property_string("path");
|
||||
int width = mp.get_property_int("video-params/w");
|
||||
int height = mp.get_property_int("video-params/h");
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
fileSize = new FileInfo(path).Length;
|
||||
|
||||
if (App.AudioTypes.Contains(Path.GetExtension(path).ToLower().TrimStart('.')))
|
||||
{
|
||||
using (MediaInfo mediaInfo = new MediaInfo(path))
|
||||
{
|
||||
performer = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Performer");
|
||||
title = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Title");
|
||||
album = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Album");
|
||||
genre = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Genre");
|
||||
date = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Recorded_Date");
|
||||
duration = mediaInfo.GetInfo(MediaInfoStreamKind.Audio, "Duration/String");
|
||||
|
||||
if (performer != "") text += "Artist: " + performer + "\n";
|
||||
if (title != "") text += "Title: " + title + "\n";
|
||||
if (album != "") text += "Album: " + album + "\n";
|
||||
if (genre != "") text += "Genre: " + genre + "\n";
|
||||
if (date != "") text += "Year: " + date + "\n";
|
||||
if (duration != "") text += "Length: " + duration + "\n";
|
||||
|
||||
mp.commandv("show-text", text, "5000");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TimeSpan position = TimeSpan.FromSeconds(mp.get_property_number("time-pos"));
|
||||
TimeSpan duration2 = TimeSpan.FromSeconds(mp.get_property_number("duration"));
|
||||
string videoFormat = mp.get_property_string("video-format").ToUpper();
|
||||
string audioCodec = mp.get_property_string("audio-codec-name").ToUpper();
|
||||
|
||||
text = Path.GetFileName(path) + "\n" +
|
||||
FormatTime(position.TotalMinutes) + ":" +
|
||||
FormatTime(position.Seconds) + " / " +
|
||||
FormatTime(duration2.TotalMinutes) + ":" +
|
||||
FormatTime(duration2.Seconds) + "\n" +
|
||||
$"{width} x {height}\n";
|
||||
|
||||
if (fileSize > 0)
|
||||
text += Convert.ToInt32(fileSize / 1024.0 / 1024.0).ToString() + " MB\n";
|
||||
|
||||
text += $"{videoFormat}\n{audioCodec}";
|
||||
|
||||
mp.commandv("show-text", text, "5000");
|
||||
string FormatTime(double value) => ((int)value).ToString("00");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Msg.ShowException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void execute_mpv_command(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
string command = VB.Interaction.InputBox("Enter a mpv command to be executed.", "Execute Command", RegistryHelp.GetString(App.RegPath, "RecentExecutedCommand"));
|
||||
if (string.IsNullOrEmpty(command)) return;
|
||||
RegistryHelp.SetObject(App.RegPath, "RecentExecutedCommand", command);
|
||||
mp.command_string(command, false);
|
||||
}));
|
||||
}
|
||||
|
||||
public static void open_url(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
string command = VB.Interaction.InputBox("Enter URL to be opened.");
|
||||
if (string.IsNullOrEmpty(command)) return;
|
||||
mp.Load(command);
|
||||
}));
|
||||
}
|
||||
|
||||
public static void load_sub(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
using (var d = new OpenFileDialog())
|
||||
{
|
||||
d.InitialDirectory = Path.GetDirectoryName(mp.get_property_string("path", false));
|
||||
d.Multiselect = true;
|
||||
if (d.ShowDialog() == DialogResult.OK)
|
||||
foreach (string i in d.FileNames)
|
||||
mp.commandv("sub-add", i);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public static void load_audio(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
using (var d = new OpenFileDialog())
|
||||
{
|
||||
d.InitialDirectory = Path.GetDirectoryName(mp.get_property_string("path", false));
|
||||
d.Multiselect = true;
|
||||
|
||||
if (d.ShowDialog() == DialogResult.OK)
|
||||
foreach (string i in d.FileNames)
|
||||
mp.commandv("audio-add", i);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public static void add_files_to_playlist(string[] args)
|
||||
{
|
||||
MainForm.Instance.Invoke(new Action(() => {
|
||||
using (var d = new OpenFileDialog() { Multiselect = true })
|
||||
if (d.ShowDialog() == DialogResult.OK)
|
||||
foreach(string file in d.FileNames)
|
||||
mp.commandv("loadfile", file, "append");
|
||||
}));
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
public static void manage_file_associations(string[] args)
|
||||
{
|
||||
using (var td = new TaskDialog<string>())
|
||||
{
|
||||
td.MainInstruction = "Choose an option.";
|
||||
td.MainIcon = MsgIcon.Shield;
|
||||
|
||||
td.AddCommandLink("Register video file extensions", "video");
|
||||
td.AddCommandLink("Register audio file extensions", "audio");
|
||||
td.AddCommandLink("Unregister file extensions", "unreg");
|
||||
|
||||
string result = td.Show();
|
||||
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
using (var proc = new Process())
|
||||
{
|
||||
proc.StartInfo.FileName = Application.ExecutablePath;
|
||||
proc.StartInfo.Arguments = "--reg-file-assoc " + result;
|
||||
proc.StartInfo.Verb = "runas";
|
||||
try {
|
||||
proc.Start();
|
||||
}
|
||||
catch (Exception)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,380 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class App
|
||||
{
|
||||
public static string ConfFilePath { get; } = mp.ConfFolder + "\\mpvnet.conf";
|
||||
public static string RegPath { get; } = "HKCU\\Software\\" + Application.ProductName;
|
||||
public static string ClipboardMonitoring { get; set; } = "yes";
|
||||
|
||||
public static string[] VideoTypes { get; } = "mkv mp4 mpg avi mov webm vob wmv flv avs 264 h264 asf webm mpeg mpv y4m avc hevc 265 h265 m2v m2ts vpy mts m4v".Split(' ');
|
||||
public static string[] AudioTypes { get; } = "mp3 mp2 ac3 ogg opus flac wav w64 m4a dts dtsma dtshr dtshd eac3 thd thd+ac3 mka aac mpa".Split(' ');
|
||||
public static string[] SubtitleTypes { get; } = "srt ass idx sup ttxt ssa smi".Split(' ');
|
||||
|
||||
public static string DarkMode { get; set; } = "always";
|
||||
public static string ProcessInstance { get; set; } = "single";
|
||||
|
||||
public static bool IsDarkMode {
|
||||
get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
foreach (var i in Conf)
|
||||
ProcessProperty(i.Key, i.Value);
|
||||
}
|
||||
|
||||
static Dictionary<string, string> _Conf;
|
||||
|
||||
public static Dictionary<string, string> Conf {
|
||||
get {
|
||||
if (_Conf == null)
|
||||
{
|
||||
_Conf = new Dictionary<string, string>();
|
||||
|
||||
if (File.Exists(ConfFilePath))
|
||||
foreach (string i in File.ReadAllLines(ConfFilePath))
|
||||
if (i.Contains("=") && !i.StartsWith("#"))
|
||||
_Conf[i.Substring(0, i.IndexOf("=")).Trim()] = i.Substring(i.IndexOf("=") + 1).Trim();
|
||||
}
|
||||
return _Conf;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ProcessProperty(string name, string value)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "clipboard-monitoring": ClipboardMonitoring = value; break;
|
||||
case "process-instance": ProcessInstance = value; break;
|
||||
case "dark-mode": DarkMode = value; break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ProcessCommandLineEarly()
|
||||
{
|
||||
var args = Environment.GetCommandLineArgs().Skip(1);
|
||||
|
||||
foreach (string i in args)
|
||||
{
|
||||
if (i.StartsWith("--"))
|
||||
{
|
||||
if (i.Contains("="))
|
||||
{
|
||||
string left = i.Substring(2, i.IndexOf("=") - 2);
|
||||
string right = i.Substring(left.Length + 3);
|
||||
mp.ProcessProperty(left, right);
|
||||
ProcessProperty(left, right);
|
||||
}
|
||||
else
|
||||
{
|
||||
string switchName = i.Substring(2);
|
||||
|
||||
switch (switchName)
|
||||
{
|
||||
case "fs":
|
||||
case "fullscreen":
|
||||
mp.Fullscreen = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Sys
|
||||
{
|
||||
public static bool IsDarkTheme {
|
||||
get {
|
||||
object value = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", 1);
|
||||
if (value is null) value = 1;
|
||||
return (int)value == 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsDirectoryWritable(string dirPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (FileStream fs = File.Create(Path.Combine(dirPath,
|
||||
Path.GetRandomFileName()), 1, FileOptions.DeleteOnClose))
|
||||
{ }
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class StringLogicalComparer : IComparer, IComparer<string>
|
||||
{
|
||||
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern int StrCmpLogical(string x, string y);
|
||||
|
||||
int IComparer_Compare(object x, object y) => StrCmpLogical(x.ToString(), y.ToString());
|
||||
int IComparer.Compare(object x, object y) => IComparer_Compare(x, y);
|
||||
int IComparerOfString_Compare(string x, string y) => StrCmpLogical(x, y);
|
||||
int IComparer<string>.Compare(string x, string y) => IComparerOfString_Compare(x, y);
|
||||
}
|
||||
|
||||
public class FileAssociation
|
||||
{
|
||||
static string ExePath = Application.ExecutablePath;
|
||||
static string ExeFilename = Path.GetFileName(Application.ExecutablePath);
|
||||
static string ExeFilenameNoExt = Path.GetFileNameWithoutExtension(Application.ExecutablePath);
|
||||
static string[] Types;
|
||||
|
||||
public static void Register(string[] types)
|
||||
{
|
||||
Types = types;
|
||||
|
||||
RegistryHelp.SetObject(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename, null, ExePath);
|
||||
RegistryHelp.SetObject($"HKCR\\Applications\\{ExeFilename}", "FriendlyAppName", "mpv.net media player");
|
||||
RegistryHelp.SetObject($"HKCR\\Applications\\{ExeFilename}\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\"");
|
||||
RegistryHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv\Capabilities", "ApplicationDescription", "mpv.net media player");
|
||||
RegistryHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv\Capabilities", "ApplicationName", "mpv.net");
|
||||
RegistryHelp.SetObject($"HKCR\\SystemFileAssociations\\video\\OpenWithList\\{ExeFilename}", null, "");
|
||||
RegistryHelp.SetObject($"HKCR\\SystemFileAssociations\\audio\\OpenWithList\\{ExeFilename}", null, "");
|
||||
|
||||
foreach (string ext in Types)
|
||||
{
|
||||
RegistryHelp.SetObject($"HKCR\\Applications\\{ExeFilename}\\SupportedTypes", "." + ext, "");
|
||||
RegistryHelp.SetObject($"HKCR\\" + "." + ext, null, ExeFilenameNoExt + "." + ext);
|
||||
RegistryHelp.SetObject($"HKCR\\" + "." + ext + "\\OpenWithProgIDs", ExeFilenameNoExt + "." + ext, "");
|
||||
if (App.VideoTypes.Contains(ext))
|
||||
RegistryHelp.SetObject($"HKCR\\" + "." + ext, "PerceivedType", "video");
|
||||
if (App.AudioTypes.Contains(ext))
|
||||
RegistryHelp.SetObject($"HKCR\\" + "." + ext, "PerceivedType", "audio");
|
||||
RegistryHelp.SetObject($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open", null, "Play with " + Application.ProductName);
|
||||
RegistryHelp.SetObject($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\"");
|
||||
RegistryHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv.net\Capabilities\FileAssociations", "." + ext, ExeFilenameNoExt + "." + ext);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Unregister()
|
||||
{
|
||||
RegistryHelp.RemoveKey(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename);
|
||||
RegistryHelp.RemoveKey($"HKCR\\Applications\\{ExeFilename}");
|
||||
RegistryHelp.RemoveKey(@"HKLM\SOFTWARE\Clients\Media\mpv.net");
|
||||
RegistryHelp.RemoveKey($"HKCR\\SystemFileAssociations\\video\\OpenWithList\\{ExeFilename}");
|
||||
RegistryHelp.RemoveKey($"HKCR\\SystemFileAssociations\\audio\\OpenWithList\\{ExeFilename}");
|
||||
|
||||
foreach (string id in Registry.ClassesRoot.GetSubKeyNames())
|
||||
{
|
||||
if (id.StartsWith(ExeFilenameNoExt + "."))
|
||||
Registry.ClassesRoot.DeleteSubKeyTree(id);
|
||||
|
||||
RegistryHelp.RemoveValue($"HKCR\\Software\\Classes\\" + id + "\\OpenWithProgIDs", ExeFilenameNoExt + id);
|
||||
RegistryHelp.RemoveValue($"HKLM\\Software\\Classes\\" + id + "\\OpenWithProgIDs", ExeFilenameNoExt + id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class RegistryHelp
|
||||
{
|
||||
public static void SetObject(string path, string name, object value)
|
||||
{
|
||||
using (RegistryKey rk = GetRootKey(path).CreateSubKey(path.Substring(5), RegistryKeyPermissionCheck.ReadWriteSubTree))
|
||||
rk.SetValue(name, value);
|
||||
}
|
||||
|
||||
public static string GetString(string path, string name)
|
||||
{
|
||||
object val = GetObject(path, name);
|
||||
if (val == null || !(val is string)) return "";
|
||||
return val.ToString();
|
||||
}
|
||||
|
||||
public static object GetObject(string path, string name)
|
||||
{
|
||||
using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5)))
|
||||
if (rk != null)
|
||||
return rk.GetValue(name, "");
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void RemoveKey(string path)
|
||||
{
|
||||
try {
|
||||
GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false);
|
||||
} catch { }
|
||||
}
|
||||
|
||||
public static void RemoveValue(string path, string name)
|
||||
{
|
||||
try {
|
||||
using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5), true))
|
||||
if (!(rk is null))
|
||||
rk.DeleteValue(name, false);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
static RegistryKey GetRootKey(string path)
|
||||
{
|
||||
switch (path.Substring(0, 4))
|
||||
{
|
||||
case "HKLM": return Registry.LocalMachine;
|
||||
case "HKCU": return Registry.CurrentUser;
|
||||
case "HKCR": return Registry.ClassesRoot;
|
||||
default: throw new Exception();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MediaTrack
|
||||
{
|
||||
public string Text { get; set; }
|
||||
public string Type { get; set; }
|
||||
public int ID { get; set; }
|
||||
}
|
||||
|
||||
public class CommandItem : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string Path { get; set; } = "";
|
||||
public string Command { get; set; } = "";
|
||||
|
||||
public CommandItem() { }
|
||||
|
||||
public CommandItem(SerializationInfo info, StreamingContext context) { }
|
||||
|
||||
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private string _Input = "";
|
||||
|
||||
public string Input {
|
||||
get => _Input;
|
||||
set {
|
||||
_Input = value;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public static ObservableCollection<CommandItem> GetItems(string content)
|
||||
{
|
||||
var items = new ObservableCollection<CommandItem>();
|
||||
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
foreach (string line in content.Split('\r', '\n'))
|
||||
{
|
||||
string val = line.Trim();
|
||||
if (val.StartsWith("#")) continue;
|
||||
if (!val.Contains(" ")) continue;
|
||||
CommandItem item = new CommandItem();
|
||||
item.Input = val.Substring(0, val.IndexOf(" "));
|
||||
if (item.Input == "_") item.Input = "";
|
||||
val = val.Substring(val.IndexOf(" ") + 1);
|
||||
|
||||
if (val.Contains("#menu:"))
|
||||
{
|
||||
item.Path = val.Substring(val.IndexOf("#menu:") + 6).Trim();
|
||||
val = val.Substring(0, val.IndexOf("#menu:"));
|
||||
if (item.Path.Contains(";"))
|
||||
item.Path = item.Path.Substring(item.Path.IndexOf(";") + 1).Trim();
|
||||
}
|
||||
|
||||
item.Command = val.Trim();
|
||||
if (item.Command == "")
|
||||
continue;
|
||||
if (item.Command.ToLower() == "ignore")
|
||||
item.Command = "";
|
||||
MigrateCommands(item);
|
||||
items.Add(item);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private static ObservableCollection<CommandItem> _Items;
|
||||
|
||||
public static ObservableCollection<CommandItem> Items {
|
||||
get {
|
||||
if (_Items is null)
|
||||
_Items = GetItems(File.ReadAllText(mp.InputConfPath));
|
||||
return _Items;
|
||||
}
|
||||
}
|
||||
|
||||
public static void MigrateCommands(CommandItem item)
|
||||
{
|
||||
switch (item.Command)
|
||||
{
|
||||
case "script-message mpv.net show-prefs":
|
||||
item.Command = "script-message mpv.net show-conf-editor";
|
||||
break;
|
||||
case "script-message mpv.net show-keys":
|
||||
item.Command = "script-message mpv.net show-input-editor";
|
||||
break;
|
||||
case "script-message mpv.net history":
|
||||
item.Command = "script-message mpv.net show-history";
|
||||
break;
|
||||
case "script-message mpv.net open-config-folder":
|
||||
item.Command = "script-message open-conf-folder";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CursorHelp
|
||||
{
|
||||
static bool IsVisible = true;
|
||||
|
||||
public static void Show()
|
||||
{
|
||||
if (!IsVisible)
|
||||
{
|
||||
Cursor.Show();
|
||||
IsVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Hide()
|
||||
{
|
||||
if (IsVisible)
|
||||
{
|
||||
Cursor.Hide();
|
||||
IsVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsPosDifferent(Point screenPos)
|
||||
{
|
||||
return
|
||||
Math.Abs(screenPos.X - Control.MousePosition.X) > 10 ||
|
||||
Math.Abs(screenPos.Y - Control.MousePosition.Y) > 10;
|
||||
}
|
||||
}
|
||||
|
||||
public class SingleProcess
|
||||
{
|
||||
public static int Message { get; } = RegisterWindowMessage("mpvnet_IPC");
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
static extern int RegisterWindowMessage(string id);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool AllowSetForegroundWindow(int dwProcessId);
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray();
|
||||
|
||||
if (args.Length == 2 && args[0] == "--reg-file-assoc")
|
||||
{
|
||||
if (args[1] == "audio") FileAssociation.Register(App.AudioTypes);
|
||||
if (args[1] == "video") FileAssociation.Register(App.VideoTypes);
|
||||
if (args[1] == "unreg") FileAssociation.Unregister();
|
||||
return;
|
||||
}
|
||||
|
||||
Mutex mutex = new Mutex(true, "mpvnetProcessInstance", out bool isFirst);
|
||||
App.Init();
|
||||
|
||||
if ((App.ProcessInstance == "single" || App.ProcessInstance == "queue") && !isFirst)
|
||||
{
|
||||
List<string> files = new List<string>();
|
||||
|
||||
foreach (string arg in args)
|
||||
if (!arg.StartsWith("--") && (File.Exists(arg) || arg == "-" || arg.StartsWith("http")))
|
||||
files.Add(arg);
|
||||
|
||||
if (files.Count > 0)
|
||||
RegistryHelp.SetObject(App.RegPath, "ShellFiles", files.ToArray());
|
||||
|
||||
RegistryHelp.SetObject(App.RegPath, "ProcessInstanceMode", App.ProcessInstance);
|
||||
|
||||
foreach(Process process in Process.GetProcessesByName("mpvnet"))
|
||||
{
|
||||
try {
|
||||
SingleProcess.AllowSetForegroundWindow(process.Id);
|
||||
Native.SendMessage(process.MainWindowHandle, SingleProcess.Message, IntPtr.Zero, IntPtr.Zero);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new MainForm());
|
||||
mutex.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Msg.ShowException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class MediaInfo : IDisposable
|
||||
{
|
||||
IntPtr Handle;
|
||||
static bool Loaded;
|
||||
|
||||
public MediaInfo(string sourcepath)
|
||||
{
|
||||
if (!Loaded)
|
||||
{
|
||||
if (LoadLibrary("MediaInfo.dll") == IntPtr.Zero)
|
||||
throw new Exception("Failed to load MediaInfo.dll.");
|
||||
|
||||
Loaded = true;
|
||||
}
|
||||
|
||||
Handle = MediaInfo_New();
|
||||
MediaInfo_Open(Handle, sourcepath);
|
||||
}
|
||||
|
||||
public string GetInfo(MediaInfoStreamKind streamKind, string parameter)
|
||||
{
|
||||
return Marshal.PtrToStringUni(MediaInfo_Get(Handle, streamKind, 0, parameter, MediaInfoInfoKind.Text, MediaInfoInfoKind.Name));
|
||||
}
|
||||
|
||||
public int GetCount(MediaInfoStreamKind streamKind) => MediaInfo_Count_Get(Handle, streamKind, -1);
|
||||
|
||||
public string GetVideo(int streamNumber, string parameter)
|
||||
{
|
||||
return Marshal.PtrToStringUni(MediaInfo_Get(Handle, MediaInfoStreamKind.Video, streamNumber, parameter, MediaInfoInfoKind.Text, MediaInfoInfoKind.Name));
|
||||
}
|
||||
|
||||
public string GetAudio(int streamNumber, string parameter)
|
||||
{
|
||||
return Marshal.PtrToStringUni(MediaInfo_Get(Handle, MediaInfoStreamKind.Audio, streamNumber, parameter, MediaInfoInfoKind.Text, MediaInfoInfoKind.Name));
|
||||
}
|
||||
|
||||
public string GetText(int streamNumber, string parameter)
|
||||
{
|
||||
return Marshal.PtrToStringUni(MediaInfo_Get(Handle, MediaInfoStreamKind.Text, streamNumber, parameter, MediaInfoInfoKind.Text, MediaInfoInfoKind.Name));
|
||||
}
|
||||
|
||||
bool Disposed;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (!Disposed)
|
||||
{
|
||||
Disposed = true;
|
||||
MediaInfo_Close(Handle);
|
||||
MediaInfo_Delete(Handle);
|
||||
}
|
||||
}
|
||||
|
||||
~MediaInfo() { Dispose(); }
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
||||
static extern IntPtr LoadLibrary(string path);
|
||||
|
||||
[DllImport("MediaInfo.dll")]
|
||||
static extern IntPtr MediaInfo_New();
|
||||
|
||||
[DllImport("MediaInfo.dll")]
|
||||
static extern void MediaInfo_Delete(IntPtr handle);
|
||||
|
||||
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
||||
static extern int MediaInfo_Open(IntPtr handle, string fileName);
|
||||
|
||||
[DllImport("MediaInfo.dll")]
|
||||
static extern int MediaInfo_Close(IntPtr handle);
|
||||
|
||||
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
||||
static extern IntPtr MediaInfo_Get(IntPtr handle,
|
||||
MediaInfoStreamKind streamKind,
|
||||
int streamNumber,
|
||||
string parameter,
|
||||
MediaInfoInfoKind kindOfInfo,
|
||||
MediaInfoInfoKind kindOfSearch);
|
||||
|
||||
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)]
|
||||
static extern int MediaInfo_Count_Get(IntPtr handle,
|
||||
MediaInfoStreamKind streamKind,
|
||||
int streamNumber);
|
||||
}
|
||||
|
||||
public enum MediaInfoStreamKind
|
||||
{
|
||||
General,
|
||||
Video,
|
||||
Audio,
|
||||
Text,
|
||||
Other,
|
||||
Image,
|
||||
Menu,
|
||||
Max,
|
||||
}
|
||||
|
||||
public enum MediaInfoInfoKind
|
||||
{
|
||||
Name,
|
||||
Text,
|
||||
Measure,
|
||||
Options,
|
||||
NameText,
|
||||
MeasureText,
|
||||
Info,
|
||||
HowTo
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class Native
|
||||
{
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr LoadLibrary(string dllToLoad);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern void ReleaseCapture();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool AdjustWindowRect(ref RECT lpRect, uint dwStyle, bool bMenu);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool EnableWindow(IntPtr hWnd, bool bEnable);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetWindowLong")]
|
||||
private static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")]
|
||||
private static extern IntPtr GetWindowLong64(IntPtr hWnd, int nIndex);
|
||||
|
||||
public static IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex)
|
||||
{
|
||||
if (IntPtr.Size == 8)
|
||||
return GetWindowLong64(hWnd, nIndex);
|
||||
else
|
||||
return GetWindowLong32(hWnd, nIndex);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT
|
||||
{
|
||||
public int Left;
|
||||
public int Top;
|
||||
public int Right;
|
||||
public int Bottom;
|
||||
|
||||
public RECT(Rectangle r)
|
||||
{
|
||||
Left = r.Left;
|
||||
Top = r.Top;
|
||||
Right = r.Right;
|
||||
Bottom = r.Bottom;
|
||||
}
|
||||
|
||||
public RECT(int left, int top, int right, int bottom)
|
||||
{
|
||||
Left = left;
|
||||
Top = top;
|
||||
Right = right;
|
||||
Bottom = bottom;
|
||||
}
|
||||
|
||||
public Rectangle ToRectangle() { return Rectangle.FromLTRB(Left, Top, Right, Bottom); }
|
||||
public Size Size => new Size(Right - Left, Bottom - Top);
|
||||
public int Width => Right - Left;
|
||||
public int Height => Bottom - Top;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public static class NativeHelp
|
||||
{
|
||||
public static int GetResizeBorder(int v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case 1 /* WMSZ_LEFT */ : return 3;
|
||||
case 3 /* WMSZ_TOP */ : return 2;
|
||||
case 2 /* WMSZ_RIGHT */ : return 3;
|
||||
case 6 /* WMSZ_BOTTOM */ : return 2;
|
||||
case 4 /* WMSZ_TOPLEFT */ : return 1;
|
||||
case 5 /* WMSZ_TOPRIGHT */ : return 1;
|
||||
case 7 /* WMSZ_BOTTOMLEFT */ : return 3;
|
||||
case 8 /* WMSZ_BOTTOMRIGHT */: return 3;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SubtractWindowBorders(IntPtr hwnd, ref Native.RECT rc)
|
||||
{
|
||||
var b = new Native.RECT(0, 0, 0, 0);
|
||||
AddWindowBorders(hwnd, ref b);
|
||||
rc.Left -= b.Left;
|
||||
rc.Top -= b.Top;
|
||||
rc.Right -= b.Right;
|
||||
rc.Bottom -= b.Bottom;
|
||||
}
|
||||
|
||||
public static void AddWindowBorders(IntPtr hwnd, ref Native.RECT rc)
|
||||
{
|
||||
Native.AdjustWindowRect(ref rc, (uint)Native.GetWindowLongPtr(hwnd, -16 /* GWL_STYLE */), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,656 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
public class Msg
|
||||
{
|
||||
private static string ShownMessages;
|
||||
|
||||
public static string SupportURL { get; set; }
|
||||
|
||||
public static void Show(string mainInstruction, string content = null)
|
||||
{
|
||||
Msg.Show(mainInstruction, content, MsgIcon.Info, MsgButtons.Ok, MsgResult.None);
|
||||
}
|
||||
|
||||
public static void ShowError(string mainInstruction, string content = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (TaskDialog<string> td = new TaskDialog<string>())
|
||||
{
|
||||
td.AllowCancel = false;
|
||||
|
||||
if (string.IsNullOrEmpty(content))
|
||||
{
|
||||
if (mainInstruction.Length < 80)
|
||||
td.MainInstruction = mainInstruction;
|
||||
else
|
||||
td.Content = mainInstruction;
|
||||
}
|
||||
else
|
||||
{
|
||||
td.MainInstruction = mainInstruction;
|
||||
td.Content = content;
|
||||
}
|
||||
|
||||
td.MainIcon = MsgIcon.Error;
|
||||
td.Footer = "[Copy Message](copymsg)";
|
||||
|
||||
if (!string.IsNullOrEmpty(Msg.SupportURL))
|
||||
td.Footer += $" [Contact Support]({SupportURL})";
|
||||
|
||||
td.Show();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.GetType().Name + "\n\n" + ex.Message + "\n\n" + ex.ToString(),
|
||||
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowException(Exception e)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (TaskDialog<string> td = new TaskDialog<string>())
|
||||
{
|
||||
td.MainInstruction = e.GetType().Name;
|
||||
td.Content = e.Message;
|
||||
td.MainIcon = MsgIcon.Error;
|
||||
td.ExpandedInformation = e.ToString();
|
||||
td.Footer = "[Copy Message](copymsg)";
|
||||
|
||||
if (!string.IsNullOrEmpty(Msg.SupportURL))
|
||||
td.Footer += $" [Contact Support]({SupportURL})";
|
||||
|
||||
td.Show();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.GetType().Name + "\n\n" + ex.Message + "\n\n" + ex.ToString(),
|
||||
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowWarning(string mainInstruction,
|
||||
string content = null,
|
||||
bool onlyOnce = false)
|
||||
{
|
||||
if (onlyOnce && Msg.ShownMessages != null &&
|
||||
Msg.ShownMessages.Contains(mainInstruction + content))
|
||||
return;
|
||||
|
||||
Msg.Show(mainInstruction, content, MsgIcon.Warning, MsgButtons.Ok, MsgResult.None);
|
||||
if (!onlyOnce) return;
|
||||
Msg.ShownMessages += mainInstruction + content;
|
||||
}
|
||||
|
||||
public static MsgResult ShowQuestion(string mainInstruction,
|
||||
MsgButtons buttons = MsgButtons.OkCancel)
|
||||
{
|
||||
return Msg.Show(mainInstruction, null, MsgIcon.None, buttons, MsgResult.None);
|
||||
}
|
||||
|
||||
public static MsgResult ShowQuestion(string mainInstruction,
|
||||
string content,
|
||||
MsgButtons buttons = MsgButtons.OkCancel)
|
||||
{
|
||||
return Msg.Show(mainInstruction, content, MsgIcon.None, buttons, MsgResult.None);
|
||||
}
|
||||
|
||||
public static MsgResult Show(string mainInstruction,
|
||||
string content,
|
||||
MsgIcon icon,
|
||||
MsgButtons buttons,
|
||||
MsgResult defaultButton = MsgResult.None)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (TaskDialog<MsgResult> td = new TaskDialog<MsgResult>())
|
||||
{
|
||||
td.AllowCancel = false;
|
||||
td.DefaultButton = defaultButton;
|
||||
td.MainIcon = icon;
|
||||
|
||||
if (content == null)
|
||||
{
|
||||
if (mainInstruction.Length < 80)
|
||||
td.MainInstruction = mainInstruction;
|
||||
else
|
||||
td.Content = mainInstruction;
|
||||
}
|
||||
else
|
||||
{
|
||||
td.MainInstruction = mainInstruction;
|
||||
td.Content = content;
|
||||
}
|
||||
if (buttons == MsgButtons.OkCancel)
|
||||
{
|
||||
td.AddButton("OK", MsgResult.OK);
|
||||
td.AddButton("Cancel", MsgResult.Cancel);
|
||||
}
|
||||
else
|
||||
td.CommonButtons = buttons;
|
||||
return td.Show();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return (MsgResult)MessageBox.Show(ex.GetType().Name + "\n\n" + ex.Message + "\n\n" + ex.ToString(),
|
||||
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TaskDialog<T> : TaskDialogNative, IDisposable
|
||||
{
|
||||
private Dictionary<int, T> IdValueDic;
|
||||
private Dictionary<int, string> IdTextDic;
|
||||
private List<int> CommandLinkShieldList;
|
||||
private IntPtr ButtonArray;
|
||||
private IntPtr RadioButtonArray;
|
||||
private List<TaskDialogNative.TASKDIALOG_BUTTON> Buttons;
|
||||
private List<TaskDialogNative.TASKDIALOG_BUTTON> RadioButtons;
|
||||
private TaskDialogNative.TASKDIALOGCONFIG Config;
|
||||
const int TDE_CONTENT = 0;
|
||||
const int TDE_EXPANDED_INFORMATION = 1;
|
||||
const int TDE_FOOTER = 2;
|
||||
const int TDE_MAIN_INSTRUCTION = 3;
|
||||
const int TDN_CREATED = 0;
|
||||
const int TDN_NAVIGATED = 1;
|
||||
const int TDN_BUTTON_CLICKED = 2;
|
||||
const int TDN_HYPERLINK_CLICKED = 3;
|
||||
const int TDN_TIMER = 4;
|
||||
const int TDN_DESTROYED = 5;
|
||||
const int TDN_RADIO_BUTTON_CLICKED = 6;
|
||||
const int TDN_DIALOG_CONSTRUCTED = 7;
|
||||
const int TDN_VERIFICATION_CLICKED = 8;
|
||||
const int TDN_HELP = 9;
|
||||
const int TDN_EXPANDO_BUTTON_CLICKED = 10;
|
||||
const int TDM_NAVIGATE_PAGE = 1125;
|
||||
const int TDM_CLICK_BUTTON = 1126;
|
||||
const int TDM_SET_MARQUEE_PROGRESS_BAR = 1127;
|
||||
const int TDM_SET_PROGRESS_BAR_STATE = 1128;
|
||||
const int TDM_SET_PROGRESS_BAR_RANGE = 1129;
|
||||
const int TDM_SET_PROGRESS_BAR_POS = 1130;
|
||||
const int TDM_SET_PROGRESS_BAR_MARQUEE = 1131;
|
||||
const int TDM_SET_ELEMENT_TEXT = 1132;
|
||||
const int TDM_CLICK_RADIO_BUTTON = 1134;
|
||||
const int TDM_ENABLE_BUTTON = 1135;
|
||||
const int TDM_ENABLE_RADIO_BUTTON = 1136;
|
||||
const int TDM_CLICK_VERIFICATION = 1137;
|
||||
const int TDM_UPDATE_ELEMENT_TEXT = 1138;
|
||||
const int TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = 1139;
|
||||
const int TDM_UPDATE_ICON = 1140;
|
||||
private T SelectedValueValue;
|
||||
private string SelectedTextValue;
|
||||
private int TimeoutValue;
|
||||
private int ExitTickCount;
|
||||
private bool disposed;
|
||||
|
||||
public TaskDialog()
|
||||
{
|
||||
IdValueDic = new Dictionary<int, T>();
|
||||
IdTextDic = new Dictionary<int, string>();
|
||||
CommandLinkShieldList = new List<int>();
|
||||
Buttons = new List<TaskDialogNative.TASKDIALOG_BUTTON>();
|
||||
RadioButtons = new List<TaskDialogNative.TASKDIALOG_BUTTON>();
|
||||
_SelectedID = -1;
|
||||
Config = new TaskDialogNative.TASKDIALOGCONFIG();
|
||||
Config.cbSize = (uint)Marshal.SizeOf(Config);
|
||||
Config.hwndParent = GetHandle();
|
||||
Config.hInstance = IntPtr.Zero;
|
||||
Config.dwFlags = TaskDialogNative.TASKDIALOG_FLAGS.TDF_ALLOW_DIALOG_CANCELLATION;
|
||||
Config.dwCommonButtons = MsgButtons.None;
|
||||
Config.MainIcon = new TaskDialogNative.TASKDIALOGCONFIG_ICON_UNION(0);
|
||||
Config.FooterIcon = new TaskDialogNative.TASKDIALOGCONFIG_ICON_UNION(0);
|
||||
Config.cxWidth = 0U;
|
||||
Config.cButtons = 0U;
|
||||
Config.cRadioButtons = 0U;
|
||||
Config.pButtons = IntPtr.Zero;
|
||||
Config.pRadioButtons = IntPtr.Zero;
|
||||
Config.nDefaultButton = 0;
|
||||
Config.nDefaultRadioButton = 0;
|
||||
Config.pszWindowTitle = ((AssemblyProductAttribute)Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), true)[0]).Product;
|
||||
Config.pszMainInstruction = "";
|
||||
Config.pszContent = "";
|
||||
Config.pfCallback = new PFTASKDIALOGCALLBACK(this.DialogProc);
|
||||
}
|
||||
|
||||
public IntPtr GetHandle()
|
||||
{
|
||||
StringBuilder lpszFileName = new StringBuilder(260);
|
||||
IntPtr foregroundWindow = TaskDialogNative.GetForegroundWindow();
|
||||
TaskDialogNative.GetWindowModuleFileName(foregroundWindow, lpszFileName, 260U);
|
||||
|
||||
if (Path.GetFileName(lpszFileName.ToString().Replace(".vshost", "")) ==
|
||||
Path.GetFileName(Assembly.GetEntryAssembly().Location))
|
||||
return foregroundWindow;
|
||||
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
public bool AllowCancel {
|
||||
set {
|
||||
if (value)
|
||||
Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_ALLOW_DIALOG_CANCELLATION;
|
||||
else
|
||||
Config.dwFlags ^= TaskDialogNative.TASKDIALOG_FLAGS.TDF_ALLOW_DIALOG_CANCELLATION;
|
||||
}
|
||||
}
|
||||
|
||||
public string MainInstruction {
|
||||
get => Config.pszMainInstruction;
|
||||
set => Config.pszMainInstruction = value;
|
||||
}
|
||||
|
||||
public string Content {
|
||||
get => Config.pszContent;
|
||||
set => Config.pszContent = ExpandMarkdownMarkup(value);
|
||||
}
|
||||
|
||||
public string ExpandedInformation {
|
||||
get => Config.pszExpandedInformation;
|
||||
set => Config.pszExpandedInformation = ExpandMarkdownMarkup(value);
|
||||
}
|
||||
|
||||
public string VerificationText {
|
||||
get => Config.pszVerificationText;
|
||||
set => Config.pszVerificationText = value;
|
||||
}
|
||||
|
||||
public MsgResult DefaultButton {
|
||||
get => (MsgResult)Config.nDefaultButton;
|
||||
set => Config.nDefaultButton = (int)value;
|
||||
}
|
||||
|
||||
public string Footer {
|
||||
get => Config.pszFooter;
|
||||
set => Config.pszFooter = ExpandMarkdownMarkup(value);
|
||||
}
|
||||
|
||||
public MsgIcon MainIcon {
|
||||
set => Config.MainIcon = new TaskDialogNative.TASKDIALOGCONFIG_ICON_UNION((int)value);
|
||||
}
|
||||
|
||||
private int _SelectedID;
|
||||
|
||||
public int SelectedID {
|
||||
get => _SelectedID;
|
||||
set {
|
||||
foreach (var i in IdValueDic)
|
||||
if (i.Key == value) _SelectedID = value;
|
||||
}
|
||||
}
|
||||
|
||||
public T SelectedValue {
|
||||
get {
|
||||
if (IdValueDic.ContainsKey(SelectedID))
|
||||
return IdValueDic[SelectedID];
|
||||
return SelectedValueValue;
|
||||
}
|
||||
set => SelectedValueValue = value;
|
||||
}
|
||||
|
||||
public string SelectedText {
|
||||
get {
|
||||
if (IdTextDic.ContainsKey(SelectedID))
|
||||
return IdTextDic[SelectedID];
|
||||
return SelectedTextValue;
|
||||
}
|
||||
set => SelectedTextValue = value;
|
||||
}
|
||||
|
||||
public bool CheckBoxChecked {
|
||||
get => (Config.dwFlags & TaskDialogNative.TASKDIALOG_FLAGS.TDF_VERIFICATION_FLAG_CHECKED) == TaskDialogNative.TASKDIALOG_FLAGS.TDF_VERIFICATION_FLAG_CHECKED;
|
||||
set {
|
||||
if (value)
|
||||
Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_VERIFICATION_FLAG_CHECKED;
|
||||
else
|
||||
Config.dwFlags ^= TaskDialogNative.TASKDIALOG_FLAGS.TDF_VERIFICATION_FLAG_CHECKED;
|
||||
}
|
||||
}
|
||||
|
||||
public MsgButtons CommonButtons {
|
||||
get => Config.dwCommonButtons;
|
||||
set => Config.dwCommonButtons = value;
|
||||
}
|
||||
|
||||
public int Timeout {
|
||||
get => Convert.ToInt32(TimeoutValue / 1000.0);
|
||||
set {
|
||||
TimeoutValue = value * 1000;
|
||||
Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_CALLBACK_TIMER;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddButton(string text, T value)
|
||||
{
|
||||
int n = 1000 + IdValueDic.Count + 1;
|
||||
IdValueDic[n] = value;
|
||||
Buttons.Add(new TaskDialogNative.TASKDIALOG_BUTTON(n, text));
|
||||
}
|
||||
|
||||
public string ExpandMarkdownMarkup(string value)
|
||||
{
|
||||
if (value.Contains("["))
|
||||
{
|
||||
Regex regex = new Regex(@"\[(.+)\]\((.+)\)");
|
||||
|
||||
if (regex.Match(value).Success)
|
||||
{
|
||||
Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_ENABLE_HYPERLINKS;
|
||||
value = regex.Replace(value, "<a href=\"$2\">$1</a>");
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public void AddCommandLink(string text, T value)
|
||||
{
|
||||
int n = 1000 + IdValueDic.Count + 1;
|
||||
IdValueDic[n] = value == null ? (T)(object)text : value;
|
||||
IdTextDic[n] = text;
|
||||
Buttons.Add(new TaskDialogNative.TASKDIALOG_BUTTON(n, text));
|
||||
Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_USE_COMMAND_LINKS;
|
||||
}
|
||||
|
||||
public void AddCommandLink(string text, string description, T value, bool setShield = false)
|
||||
{
|
||||
int n = 1000 + IdValueDic.Count + 1;
|
||||
IdValueDic[n] = value;
|
||||
if (setShield) CommandLinkShieldList.Add(n);
|
||||
if (!string.IsNullOrEmpty(description)) text += "\n" + description;
|
||||
Buttons.Add(new TaskDialogNative.TASKDIALOG_BUTTON(n, text));
|
||||
Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_USE_COMMAND_LINKS;
|
||||
}
|
||||
|
||||
public void AddRadioButton(string text, T value)
|
||||
{
|
||||
int n = 1000 + IdValueDic.Count + 1;
|
||||
IdValueDic[n] = value;
|
||||
RadioButtons.Add(new TaskDialogNative.TASKDIALOG_BUTTON(n, text));
|
||||
}
|
||||
|
||||
public T Show()
|
||||
{
|
||||
MarshalDialogControlStructs();
|
||||
TaskDialogNative.TASKDIALOGCONFIG config = Config;
|
||||
int errorCode = TaskDialogNative.TaskDialogIndirect(config, out int dummy1, out int dummy2, out bool isChecked);
|
||||
if (errorCode < 0) Marshal.ThrowExceptionForHR(errorCode);
|
||||
CheckBoxChecked = isChecked;
|
||||
if (SelectedValue is MsgResult) SelectedValue = (T)(object)SelectedID;
|
||||
return SelectedValue;
|
||||
}
|
||||
|
||||
public int DialogProc(IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam, IntPtr lpRefData)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case 0: //TDN_CREATED
|
||||
foreach (var i in CommandLinkShieldList)
|
||||
SendMessage(hwnd, TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE, new IntPtr(i), new IntPtr(1));
|
||||
break;
|
||||
case 2: //TDN_BUTTON_CLICKED
|
||||
case 6: //TDN_RADIO_BUTTON_CLICKED
|
||||
if (SelectedValue is MsgResult)
|
||||
_SelectedID = wParam.ToInt32();
|
||||
else
|
||||
SelectedID = wParam.ToInt32();
|
||||
break;
|
||||
case 3: //TDN_HYPERLINK_CLICKED
|
||||
string stringUni = Marshal.PtrToStringUni(lParam);
|
||||
if (stringUni.StartsWith("mailto") || stringUni.StartsWith("http"))
|
||||
Process.Start(stringUni);
|
||||
if (stringUni == "copymsg")
|
||||
{
|
||||
Thread thread = new Thread((ThreadStart)(() => {
|
||||
Clipboard.SetText(MainInstruction + "\r\n\r\n" + Content + "\r\n\r\n" + ExpandedInformation);
|
||||
MessageBox.Show("Message was copied to clipboard.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}));
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
}
|
||||
break;
|
||||
case 4: //TDN_TIMER
|
||||
if (ExitTickCount == 0) ExitTickCount = Environment.TickCount + Timeout * 1000;
|
||||
if (Environment.TickCount > ExitTickCount)
|
||||
TaskDialogNative.SendMessage(hwnd, 1126, new IntPtr(1), IntPtr.Zero);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void MarshalDialogControlStructs()
|
||||
{
|
||||
if (Buttons != null && Buttons.Count > 0)
|
||||
{
|
||||
ButtonArray = TaskDialog<T>.AllocateAndMarshalButtons(Buttons);
|
||||
Config.pButtons = ButtonArray;
|
||||
Config.cButtons = (uint)Buttons.Count;
|
||||
}
|
||||
|
||||
if (RadioButtons == null || RadioButtons.Count <= 0) return;
|
||||
RadioButtonArray = TaskDialog<T>.AllocateAndMarshalButtons(RadioButtons);
|
||||
Config.pRadioButtons = RadioButtonArray;
|
||||
Config.cRadioButtons = (uint)RadioButtons.Count;
|
||||
}
|
||||
|
||||
public static IntPtr AllocateAndMarshalButtons(List<TaskDialogNative.TASKDIALOG_BUTTON> structs)
|
||||
{
|
||||
var initialPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(TASKDIALOG_BUTTON)) * structs.Count);
|
||||
var currentPtr = initialPtr;
|
||||
|
||||
foreach (var button in structs)
|
||||
{
|
||||
Marshal.StructureToPtr(button, currentPtr, false);
|
||||
currentPtr = (IntPtr)(currentPtr.ToInt64() + Marshal.SizeOf(button));
|
||||
}
|
||||
|
||||
return initialPtr;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~TaskDialog()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
protected void Dispose(bool disposing)
|
||||
{
|
||||
if (disposed) return;
|
||||
disposed = true;
|
||||
|
||||
if (ButtonArray != IntPtr.Zero)
|
||||
{
|
||||
Marshal.FreeHGlobal(ButtonArray);
|
||||
ButtonArray = IntPtr.Zero;
|
||||
}
|
||||
|
||||
if (RadioButtonArray != IntPtr.Zero)
|
||||
{
|
||||
Marshal.FreeHGlobal(RadioButtonArray);
|
||||
RadioButtonArray = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public delegate int PFTASKDIALOGCALLBACK(
|
||||
IntPtr hwnd,
|
||||
uint msg,
|
||||
IntPtr wParam,
|
||||
IntPtr lParam,
|
||||
IntPtr lpRefData);
|
||||
|
||||
public class TaskDialogNative
|
||||
{
|
||||
[DllImport("comctl32", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
public static extern int TaskDialogIndirect(
|
||||
[In] TaskDialogNative.TASKDIALOGCONFIG pTaskConfig,
|
||||
out int pnButton,
|
||||
out int pnRadioButton,
|
||||
[MarshalAs(UnmanagedType.Bool)] out bool pVerificationFlagChecked);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetForegroundWindow();
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern uint GetWindowModuleFileName(
|
||||
IntPtr hwnd,
|
||||
StringBuilder lpszFileName,
|
||||
uint cchFileNameMax);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr SendMessage(
|
||||
IntPtr handle,
|
||||
int message,
|
||||
IntPtr wParam,
|
||||
IntPtr lParam);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)]
|
||||
public class TASKDIALOGCONFIG
|
||||
{
|
||||
public uint cbSize;
|
||||
public IntPtr hwndParent;
|
||||
public IntPtr hInstance;
|
||||
public TaskDialogNative.TASKDIALOG_FLAGS dwFlags;
|
||||
public MsgButtons dwCommonButtons;
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string pszWindowTitle;
|
||||
public TaskDialogNative.TASKDIALOGCONFIG_ICON_UNION MainIcon;
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string pszMainInstruction;
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string pszContent;
|
||||
public uint cButtons;
|
||||
public IntPtr pButtons;
|
||||
public int nDefaultButton;
|
||||
public uint cRadioButtons;
|
||||
public IntPtr pRadioButtons;
|
||||
public int nDefaultRadioButton;
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string pszVerificationText;
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string pszExpandedInformation;
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string pszExpandedControlText;
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string pszCollapsedControlText;
|
||||
public TaskDialogNative.TASKDIALOGCONFIG_ICON_UNION FooterIcon;
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string pszFooter;
|
||||
public PFTASKDIALOGCALLBACK pfCallback;
|
||||
public IntPtr lpCallbackData;
|
||||
public uint cxWidth;
|
||||
}
|
||||
|
||||
public enum TASKDIALOG_FLAGS
|
||||
{
|
||||
NONE = 0,
|
||||
TDF_ENABLE_HYPERLINKS = 1,
|
||||
TDF_USE_HICON_MAIN = 2,
|
||||
TDF_USE_HICON_FOOTER = 4,
|
||||
TDF_ALLOW_DIALOG_CANCELLATION = 8,
|
||||
TDF_USE_COMMAND_LINKS = 16,
|
||||
TDF_USE_COMMAND_LINKS_NO_ICON = 32,
|
||||
TDF_EXPAND_FOOTER_AREA = 64,
|
||||
TDF_EXPANDED_BY_DEFAULT = 128,
|
||||
TDF_VERIFICATION_FLAG_CHECKED = 256,
|
||||
TDF_SHOW_PROGRESS_BAR = 512,
|
||||
TDF_SHOW_MARQUEE_PROGRESS_BAR = 1024,
|
||||
TDF_CALLBACK_TIMER = 2048,
|
||||
TDF_POSITION_RELATIVE_TO_WINDOW = 4096,
|
||||
TDF_RTL_LAYOUT = 8192,
|
||||
TDF_NO_DEFAULT_RADIO_BUTTON = 16384,
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)]
|
||||
public struct TASKDIALOGCONFIG_ICON_UNION
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public int hMainIcon;
|
||||
[FieldOffset(0)]
|
||||
public int pszIcon;
|
||||
[FieldOffset(0)]
|
||||
public IntPtr spacer;
|
||||
|
||||
public TASKDIALOGCONFIG_ICON_UNION(int i)
|
||||
{
|
||||
this = new TaskDialogNative.TASKDIALOGCONFIG_ICON_UNION();
|
||||
spacer = IntPtr.Zero;
|
||||
pszIcon = 0;
|
||||
hMainIcon = i;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)]
|
||||
public struct TASKDIALOG_BUTTON
|
||||
{
|
||||
public int nButtonID;
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string pszButtonText;
|
||||
|
||||
public TASKDIALOG_BUTTON(int n, string txt)
|
||||
{
|
||||
this = new TaskDialogNative.TASKDIALOG_BUTTON();
|
||||
nButtonID = n;
|
||||
pszButtonText = txt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum MsgButtons
|
||||
{
|
||||
None = 0,
|
||||
Ok = 1,
|
||||
Yes = 2,
|
||||
No = 4,
|
||||
YesNo = 6,
|
||||
Cancel = 8,
|
||||
OkCancel = 9,
|
||||
YesNoCancel = 14,
|
||||
Retry = 16,
|
||||
RetryCancel = 24,
|
||||
Close = 32,
|
||||
}
|
||||
|
||||
public enum MsgResult
|
||||
{
|
||||
None,
|
||||
OK,
|
||||
Cancel,
|
||||
Abort,
|
||||
Retry,
|
||||
Ignore,
|
||||
Yes,
|
||||
No,
|
||||
}
|
||||
|
||||
public enum MsgIcon
|
||||
{
|
||||
None = 0,
|
||||
SecurityShieldGray = 65527,
|
||||
SecuritySuccess = 65528,
|
||||
SecurityError = 65529,
|
||||
SecurityWarning = 65530,
|
||||
SecurityShieldBlue = 65531,
|
||||
Shield = 65532,
|
||||
Info = 65533,
|
||||
Error = 65534,
|
||||
Warning = 65535,
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
|
||||
# This file defines the input (keys and mouse) bindings of mpv and mpv.net
|
||||
# and it also defines the context menu of mpv.net. mpv.net has an input
|
||||
# editor and an config editor as alternative to editing conf text files.
|
||||
# The input and config editor can be found in mpv.net's context menu at:
|
||||
|
||||
# Settings > Show Config Editor
|
||||
# Settings > Show Input Editor
|
||||
|
||||
# The defaults of this file can be found at:
|
||||
|
||||
# https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt
|
||||
|
||||
# the defaults of mpv can be found at:
|
||||
|
||||
# https://github.com/mpv-player/mpv/blob/master/etc/input.conf
|
||||
|
||||
# mpv.net's defaults of mpv.conf contain: 'input-default-bindings = no'
|
||||
# which disables mpv's input defaults. Every line in this file begins with a
|
||||
# space character to make it easier to do a text search, so if you want to know
|
||||
# if 'o' has already a binding you can make a text search on ' o '.
|
||||
|
||||
# mpv input commands: https://github.com/stax76/mpv.net/wiki/mpv-input-commands
|
||||
|
||||
# mpv input keys: https://github.com/stax76/mpv.net/wiki/mpv-input-keys
|
||||
|
||||
o script-message mpv.net open-files #menu: Open > Open Files...
|
||||
u script-message mpv.net open-url #menu: Open > Open URL...
|
||||
_ ignore #menu: Open > -
|
||||
Alt+a script-message mpv.net load-audio #menu: Open > Load external audio files...
|
||||
Alt+s script-message mpv.net load-sub #menu: Open > Load external subtitle files...
|
||||
_ ignore #menu: Open > -
|
||||
_ script-message mpv.net add-files-to-playlist #menu: Open > Add files to playlist...
|
||||
Ctrl+S script-message mpv.net show-media-search #menu: Open > Show media search...
|
||||
_ ignore #menu: Open > -
|
||||
_ ignore #menu: Open > Recent
|
||||
|
||||
_ ignore #menu: -
|
||||
Space cycle pause #menu: Play/Pause
|
||||
s stop #menu: Stop
|
||||
_ ignore #menu: -
|
||||
Enter cycle fullscreen #menu: Toggle Fullscreen
|
||||
|
||||
F11 playlist-prev #menu: Navigate > Previous File
|
||||
F12 playlist-next #menu: Navigate > Next File
|
||||
_ ignore #menu: Navigate > -
|
||||
PGUP add chapter 1 #menu: Navigate > Next Chapter
|
||||
PGDWN add chapter -1 #menu: Navigate > Previous Chapter
|
||||
_ ignore #menu: Navigate > -
|
||||
. frame-step #menu: Navigate > Jump Next Frame
|
||||
, frame-back-step #menu: Navigate > Jump Previous Frame
|
||||
_ ignore #menu: Navigate > -
|
||||
Right no-osd seek 7 #menu: Navigate > Jump 7 sec forward
|
||||
Left no-osd seek -7 #menu: Navigate > Jump 7 sec backward
|
||||
_ ignore #menu: Navigate > -
|
||||
Up no-osd seek 40 #menu: Navigate > Jump 40 sec forward
|
||||
Down no-osd seek -40 #menu: Navigate > Jump 40 sec backward
|
||||
_ ignore #menu: Navigate > -
|
||||
Ctrl+Right no-osd seek 300 #menu: Navigate > Jump 5 min forward
|
||||
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 > Decrease Size
|
||||
_ ignore #menu: Pan & Scan > -
|
||||
Ctrl+KP4 add video-pan-x -0.01 #menu: Pan & Scan > Move Left
|
||||
Ctrl+KP6 add video-pan-x 0.01 #menu: Pan & Scan > Move Right
|
||||
_ ignore #menu: Pan & Scan > -
|
||||
Ctrl+KP8 add video-pan-y -0.01 #menu: Pan & Scan > Move Up
|
||||
Ctrl+KP2 add video-pan-y 0.01 #menu: Pan & Scan > Move Down
|
||||
_ ignore #menu: Pan & Scan > -
|
||||
w add panscan -0.1 #menu: Pan & Scan > Decrease Height
|
||||
W add panscan 0.1 #menu: Pan & Scan > Increase Height
|
||||
_ ignore #menu: Pan & Scan > -
|
||||
Ctrl+BS set video-zoom 0; set video-pan-x 0; set video-pan-y 0 #menu: Pan & Scan > Reset
|
||||
|
||||
Ctrl+1 add contrast -1 #menu: Video > Decrease Contrast
|
||||
Ctrl+2 add contrast 1 #menu: Video > Increase Contrast
|
||||
_ ignore #menu: Video > -
|
||||
Ctrl+3 add brightness -1 #menu: Video > Decrease Brightness
|
||||
Ctrl+4 add brightness 1 #menu: Video > Increase Brightness
|
||||
_ ignore #menu: Video > -
|
||||
Ctrl+5 add gamma -1 #menu: Video > Decrease Gamma
|
||||
Ctrl+6 add gamma 1 #menu: Video > Increase Gamma
|
||||
_ ignore #menu: Video > -
|
||||
Ctrl+7 add saturation -1 #menu: Video > Decrease Saturation
|
||||
Ctrl+8 add saturation 1 #menu: Video > Increase Saturation
|
||||
_ ignore #menu: Video > -
|
||||
Ctrl+s async screenshot #menu: Video > Take Screenshot
|
||||
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
|
||||
|
||||
KP7 script-message mpv.net cycle-audio #menu: Audio > Cycle/Next
|
||||
_ ignore #menu: Audio > -
|
||||
KP6 add audio-delay 0.1 #menu: Audio > Delay +0.1
|
||||
KP9 add audio-delay -0.1 #menu: Audio > Delay -0.1
|
||||
|
||||
KP8 cycle sub #menu: Subtitle > Cycle/Next
|
||||
v cycle sub-visibility #menu: Subtitle > Toggle Visibility
|
||||
_ ignore #menu: Subtitle > -
|
||||
z add sub-delay -0.1 #menu: Subtitle > Delay -0.1
|
||||
Z add sub-delay 0.1 #menu: Subtitle > Delay +0.1
|
||||
_ ignore #menu: Subtitle > -
|
||||
r add sub-pos -1 #menu: Subtitle > Move Up
|
||||
R add sub-pos +1 #menu: Subtitle > Move Down
|
||||
_ ignore #menu: Subtitle > -
|
||||
_ add sub-scale -0.1 #menu: Subtitle > Decrease Subtitle Font Size
|
||||
_ add sub-scale 0.1 #menu: Subtitle > Increase Subtitle Font Size
|
||||
|
||||
_ ignore #menu: Track
|
||||
|
||||
+ add volume 10 #menu: Volume > Up
|
||||
- add volume -10 #menu: Volume > Down
|
||||
_ ignore #menu: Volume > -
|
||||
m cycle mute #menu: Volume > Mute
|
||||
|
||||
[ multiply speed 1/1.1 #menu: Speed > -10%
|
||||
] multiply speed 1.1 #menu: Speed > +10%
|
||||
_ ignore #menu: Speed > -
|
||||
{ multiply speed 0.5 #menu: Speed > Half
|
||||
} multiply speed 2.0 #menu: Speed > Double
|
||||
_ ignore #menu: Speed > -
|
||||
BS set speed 1 #menu: Speed > Reset
|
||||
|
||||
KP0 script-message rate-file 0 #menu: Extensions > Rating > 0stars
|
||||
KP1 script-message rate-file 1 #menu: Extensions > Rating > 1stars
|
||||
KP2 script-message rate-file 2 #menu: Extensions > Rating > 2stars
|
||||
KP3 script-message rate-file 3 #menu: Extensions > Rating > 3stars
|
||||
KP4 script-message rate-file 4 #menu: Extensions > Rating > 4stars
|
||||
KP5 script-message rate-file 5 #menu: Extensions > Rating > 5stars
|
||||
|
||||
Ctrl+t set ontop yes #menu: View > On Top > Enable
|
||||
Ctrl+T set ontop no #menu: View > On Top > Disable
|
||||
i script-message mpv.net show-info #menu: View > File Info
|
||||
t script-binding stats/display-stats #menu: View > Show Statistics
|
||||
T script-binding stats/display-stats-toggle #menu: View > Toggle Statistics
|
||||
Del script-binding osc/visibility #menu: View > Toggle OSC Visibility
|
||||
F8 show-text ${playlist} 5000 #menu: View > Show Playlist
|
||||
F9 show-text ${track-list} 5000 #menu: View > Show Audio/Video/Subtitle List
|
||||
|
||||
c script-message mpv.net show-conf-editor #menu: Settings > Show Config Editor
|
||||
Ctrl+i script-message mpv.net show-input-editor #menu: Settings > Show Input Editor
|
||||
Ctrl+f script-message mpv.net open-conf-folder #menu: Settings > Open Config Folder
|
||||
|
||||
Ctrl+P script-message mpv.net show-command-palette #menu: Tools > Command Palette
|
||||
h script-message mpv.net show-history #menu: Tools > Show History
|
||||
l ab-loop #menu: Tools > Set/clear A-B loop points
|
||||
L cycle-values loop-file "inf" "no" #menu: Tools > Toggle infinite file looping
|
||||
Ctrl+h cycle-values hwdec "auto" "no" #menu: Tools > Cycle Hardware Decoding
|
||||
_ script-message mpv.net execute-mpv-command #menu: Tools > Execute mpv command...
|
||||
_ script-message mpv.net manage-file-associations #menu: Tools > Manage File Associations...
|
||||
|
||||
_ script-message mpv.net shell-execute https://mpv.io/manual/stable/ #menu: Help > Show mpv manual
|
||||
_ script-message mpv.net shell-execute https://github.com/mpv-player/mpv/blob/master/etc/input.conf #menu: Help > Show mpv default keys
|
||||
_ script-message mpv.net shell-execute https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt #menu: Help > Show mpv.net default keys
|
||||
_ script-message mpv.net shell-execute https://mpv-net.github.io/mpv.net-web-site/ #menu: Help > Show mpv.net web site
|
||||
_ script-message mpv.net shell-execute https://github.com/stax76/mpv.net/blob/master/Manual.md #menu: Help > Show mpv.net manual
|
||||
_ ignore #menu: Help > -
|
||||
_ script-message mpv.net show-about #menu: Help > About mpv.net
|
||||
|
||||
_ ignore #menu: -
|
||||
Esc quit #menu: Exit
|
||||
Q quit-watch-later #menu: Exit Watch Later
|
||||
|
||||
> playlist-next
|
||||
< playlist-prev
|
||||
Power quit
|
||||
Play cycle pause
|
||||
Pause cycle pause
|
||||
PlayPause cycle pause
|
||||
Stop stop
|
||||
Forward seek 60
|
||||
Rewind seek -60
|
||||
Mute cycle mute
|
||||
Volume_Up add volume 10
|
||||
Volume_Down add volume -10
|
||||
Wheel_Up add volume 10
|
||||
Wheel_Down add volume -10
|
||||
Prev playlist-prev
|
||||
Next playlist-next
|
||||
|
||||
MBTN_LEFT_DBL cycle fullscreen
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
# This file defines the input (keys and mouse) bindings of mpv and mpv.net
|
||||
# and it also defines the context menu of mpv.net. mpv.net has an input
|
||||
# editor and an config editor as alternatives to editing conf text files.
|
||||
# The input and config editor can be found in mpv.net's context menu at:
|
||||
|
||||
# Settings > Show Config Editor
|
||||
# Settings > Show Input Editor
|
||||
|
||||
# The defaults of this file can be found at:
|
||||
|
||||
# https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt
|
||||
|
||||
# the defaults of mpv can be found at:
|
||||
|
||||
# https://github.com/mpv-player/mpv/blob/master/etc/inputConf
|
||||
|
||||
# mpv.net's defaults of mpv.conf contain: 'input-default-bindings = no'
|
||||
# which disables mpv's input defaults. Every line in this file begins with a
|
||||
# space character to make it easier to do a text search, so if you want to know
|
||||
# if 'o' has already a binding you can make a text search on ' o '.
|
||||
|
||||
# mpv input commands: https://github.com/stax76/mpv.net/wiki/mpv-input-commands
|
||||
|
||||
# mpv input keys: https://github.com/stax76/mpv.net/wiki/mpv-input-keys
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
# mpv manual: https://mpv.io/manual/master/
|
||||
|
||||
# mpv.net mpv.conf defaults: https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpvConf.txt
|
||||
|
||||
input-ar-delay = 500
|
||||
input-ar-rate = 20
|
||||
volume = 50
|
||||
hwdec = yes
|
||||
keep-open = yes
|
||||
keep-open-pause = no
|
||||
osd-playing-msg = ${filename}
|
||||
screenshot-directory = ~~desktop/
|
||||
input-default-bindings = no
|
||||
@@ -1,25 +0,0 @@
|
||||
[[settings]]
|
||||
name = "dark-mode"
|
||||
default = "always"
|
||||
filter = "mpv.net"
|
||||
help = "Enables a dark theme."
|
||||
options = [{ name = "always" },
|
||||
{ name = "system" , help = "Available on Windows 10 or higher" },
|
||||
{ name = "never" }]
|
||||
|
||||
[[settings]]
|
||||
name = "clipboard-monitoring"
|
||||
default = "yes"
|
||||
filter = "mpv.net"
|
||||
help = "Monitors the clipboard for URLs to play."
|
||||
options = [{ name = "yes" },
|
||||
{ name = "no" }]
|
||||
|
||||
[[settings]]
|
||||
name = "process-instance"
|
||||
default = "single"
|
||||
filter = "mpv.net"
|
||||
help = "Defines if more then one mpv.net process is allowed."
|
||||
options = [{ name = "multi", help = "Create a new process everytime the shell starts mpv.net" },
|
||||
{ name = "single", help = "Force a single process everytime the shell starts mpv.net" },
|
||||
{ name = "queue", help = "Force a single process and add files to playlist" }]
|
||||
|
Before Width: | Height: | Size: 6.7 KiB |
@@ -1,127 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Management.Automation.Runspaces;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class PowerShellScript
|
||||
{
|
||||
public static object Execute(string code, string[] parameters)
|
||||
{
|
||||
using (Runspace runspace = RunspaceFactory.CreateRunspace())
|
||||
{
|
||||
runspace.ApartmentState = ApartmentState.STA;
|
||||
runspace.ThreadOptions = PSThreadOptions.UseCurrentThread;
|
||||
runspace.Open();
|
||||
|
||||
using (Pipeline pipeline = runspace.CreatePipeline())
|
||||
{
|
||||
pipeline.Commands.AddScript(
|
||||
@"Using namespace mpvnet;
|
||||
Using namespace System;
|
||||
[System.Reflection.Assembly]::LoadWithPartialName(""mpvnet"")");
|
||||
|
||||
pipeline.Commands.AddScript(code);
|
||||
|
||||
try
|
||||
{
|
||||
var ret = pipeline.Invoke(parameters);
|
||||
|
||||
if (ret.Count > 0)
|
||||
return ret[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Pipeline pipeline2 = runspace.CreatePipeline())
|
||||
{
|
||||
pipeline2.Commands.AddScript("$PSVersionTable.PSVersion.Major * 10 +" +
|
||||
"$PSVersionTable.PSVersion.Minor");
|
||||
|
||||
if (Convert.ToInt32(pipeline2.Invoke()[0].ToString()) < 51)
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
Msg.ShowError("PowerShell Setup Problem\n\nEnsure you have at least PowerShell 5.1 installed.", ex2.ToString());
|
||||
return null;
|
||||
}
|
||||
Msg.ShowException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void Init(string filePath)
|
||||
{
|
||||
foreach (var eventInfo in typeof(mp).GetEvents())
|
||||
{
|
||||
if (eventInfo.Name.ToLower() ==
|
||||
Path.GetFileNameWithoutExtension(filePath).ToLower().Replace("-", ""))
|
||||
{
|
||||
PowerShellEventObject eventObject = new PowerShellEventObject();
|
||||
MethodInfo mi;
|
||||
eventObject.FilePath = filePath;
|
||||
|
||||
if (eventInfo.EventHandlerType == typeof(Action))
|
||||
{
|
||||
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.Invoke));
|
||||
}
|
||||
else if (eventInfo.EventHandlerType == typeof(Action<EndFileEventMode>))
|
||||
{
|
||||
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.InvokeEndFileEventMode));
|
||||
}
|
||||
else if (eventInfo.EventHandlerType == typeof(Action<string[]>))
|
||||
{
|
||||
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.InvokeStrings));
|
||||
}
|
||||
else
|
||||
throw new Exception();
|
||||
|
||||
eventObject.EventInfo = eventInfo;
|
||||
Delegate handler = Delegate.CreateDelegate(eventInfo.EventHandlerType, eventObject, mi);
|
||||
eventObject.Delegate = handler;
|
||||
eventInfo.AddEventHandler(eventObject, handler);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Task.Run(() =>
|
||||
{
|
||||
PowerShellScript.Execute(File.ReadAllText(filePath), new string[] {});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class PowerShellEventObject
|
||||
{
|
||||
public EventInfo EventInfo { get; set; }
|
||||
public Delegate Delegate { get; set; }
|
||||
public string FilePath { get; set; }
|
||||
|
||||
public void Invoke()
|
||||
{
|
||||
Task.Run(() => { PowerShellScript.Execute(File.ReadAllText(FilePath), new string[] { }); });
|
||||
}
|
||||
|
||||
public void InvokeEndFileEventMode(EndFileEventMode arg)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
PowerShellScript.Execute(File.ReadAllText(FilePath), new string[] { arg.ToString() });
|
||||
});
|
||||
}
|
||||
|
||||
public void InvokeStrings(string[] args)
|
||||
{
|
||||
Task.Run(() => {
|
||||
PowerShellScript.Execute(File.ReadAllText(FilePath), args);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
using Microsoft.Scripting;
|
||||
using Microsoft.Scripting.Hosting;
|
||||
|
||||
using IronPython.Hosting;
|
||||
using IronPython.Runtime;
|
||||
using IronPython.Runtime.Operations;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class PythonScript
|
||||
{
|
||||
ScriptEngine engine;
|
||||
ScriptScope scope;
|
||||
|
||||
public PythonScript(string code)
|
||||
{
|
||||
try
|
||||
{
|
||||
engine = Python.CreateEngine();
|
||||
scope = engine.CreateScope();
|
||||
scope.ImportModule("clr");
|
||||
engine.Execute("import clr", scope);
|
||||
engine.Execute("clr.AddReference(\"mpvnet\")", scope);
|
||||
engine.Execute("import mpvnet", scope);
|
||||
engine.Execute("from mpvnet import *", scope);
|
||||
engine.Execute(code, scope);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex is SyntaxErrorException e)
|
||||
Msg.ShowError($"{e.Line}, {e.Column}: " + ex.Message);
|
||||
else
|
||||
Msg.ShowException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PythonEventObject
|
||||
{
|
||||
public PythonFunction PythonFunction { get; set; }
|
||||
public EventInfo EventInfo { get; set; }
|
||||
public Delegate Delegate { get; set; }
|
||||
|
||||
public void Invoke() => PythonCalls.Call(PythonFunction);
|
||||
|
||||
public void InvokeEndFileEventMode(EndFileEventMode arg)
|
||||
{
|
||||
PythonCalls.Call(PythonFunction, new[] { arg });
|
||||
}
|
||||
|
||||
public void InvokeStrings(string[] arg)
|
||||
{
|
||||
PythonCalls.Call(PythonFunction, new[] { arg });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<Window x:Class="mpvnet.AboutWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Title="About mpv.net" Height="230" Width="420" FontSize="16" ShowInTaskbar="False"
|
||||
WindowStartupLocation="CenterOwner" ResizeMode="NoResize">
|
||||
<Grid>
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock FontSize="48" HorizontalAlignment="Center" Margin="0,0,0,10">mpv.net</TextBlock>
|
||||
<TextBlock HorizontalAlignment="Center">Copyright (c) 2017-2019 Frank Skare (stax76)</TextBlock>
|
||||
<TextBlock Name="Version" HorizontalAlignment="Center" />
|
||||
<TextBlock HorizontalAlignment="Center" Margin="0,0,0,20">MIT License</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,35 +0,0 @@
|
||||
<Window x:Class="mpvnet.CommandPaletteWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Title="Command Palette" Height="295" Width="400" ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterOwner" Loaded="Window_Loaded" FontSize="13">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox Name="FilterTextBox" PreviewKeyDown="FilterTextBox_PreviewKeyDown" TextChanged="FilterTextBox_TextChanged"></TextBox>
|
||||
<ListView Name="ListView" Grid.Row="1" MouseUp="ListView_MouseUp">
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding Path}"></TextBlock>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Input}" HorizontalAlignment="Right"></TextBlock>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,36 +0,0 @@
|
||||
<Window xmlns:Controls="clr-namespace:Controls" x:Name="ConfWindow1" x:Class="mpvnet.ConfWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:WPF="clr-namespace:WPF"
|
||||
mc:Ignorable="d"
|
||||
Height="500" Width="700" Loaded="ConfWindow1_Loaded" ShowInTaskbar="False"
|
||||
WindowStartupLocation="CenterScreen" Title="Config Editor">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Controls:SearchTextBoxUserControl HintText="Find a setting" x:Name="SearchControl" Width="250" Margin="0,20,0,0" Grid.ColumnSpan="2"/>
|
||||
<ScrollViewer x:Name="MainScrollViewer" VerticalScrollBarVisibility="Auto" Grid.Row="1" Grid.Column="2" Margin="0,0,0,10">
|
||||
<StackPanel x:Name="MainStackPanel"></StackPanel>
|
||||
</ScrollViewer>
|
||||
<StackPanel Margin="20,0,0,0" Grid.Row="1">
|
||||
<ListBox x:Name="FilterListBox" ItemsSource="{Binding FilterStrings}" BorderThickness="0" SelectionChanged="ListBox_SelectionChanged" Foreground="{x:Static WPF:WPF.ThemeBrush}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding}" FontSize="16" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<TextBlock x:Name="OpenSettingsTextBlock" Margin="0,30,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static WPF:WPF.ThemeBrush}" MouseUp="OpenSettingsTextBlock_MouseUp">Open config folder</TextBlock>
|
||||
<TextBlock x:Name="ShowManualTextBlock" Margin="0,15,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static WPF:WPF.ThemeBrush}" MouseUp="ShowManualTextBlock_MouseUp">Show mpv manual</TextBlock>
|
||||
<TextBlock x:Name="SupportTextBlock" Margin="0,15,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static WPF:WPF.ThemeBrush}" MouseUp="SupportTextBlock_MouseUp">Show support forum</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,251 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Linq;
|
||||
|
||||
using DynamicGUI;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public partial class ConfWindow : Window
|
||||
{
|
||||
private List<SettingBase> SettingsDefinitions = Settings.LoadSettings(Properties.Resources.mpvConfToml);
|
||||
private List<SettingBase> NetSettingsDefinitions = Settings.LoadSettings(Properties.Resources.mpvNetConfToml);
|
||||
private Dictionary<string, Dictionary<string, string>> Comments = new Dictionary<string, Dictionary<string, string>>();
|
||||
|
||||
public ObservableCollection<string> FilterStrings { get; } = new ObservableCollection<string>();
|
||||
|
||||
public ConfWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged;
|
||||
LoadSettings(SettingsDefinitions, Conf);
|
||||
LoadSettings(NetSettingsDefinitions, NetConf);
|
||||
SearchControl.Text = RegistryHelp.GetString(@"HKCU\Software\mpv.net", "config editor search");
|
||||
|
||||
if (App.IsDarkMode)
|
||||
{
|
||||
Foreground = Brushes.White;
|
||||
Foreground2 = Brushes.Silver;
|
||||
Background = Brushes.Black;
|
||||
}
|
||||
}
|
||||
|
||||
public Brush Foreground2 {
|
||||
get { return (Brush)GetValue(Foreground2Property); }
|
||||
set { SetValue(Foreground2Property, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty Foreground2Property =
|
||||
DependencyProperty.Register("Foreground2", typeof(Brush), typeof(ConfWindow), new PropertyMetadata(Brushes.DarkSlateGray));
|
||||
|
||||
private void LoadSettings(List<SettingBase> settingsDefinitions,
|
||||
Dictionary<string, string> confSettings)
|
||||
{
|
||||
foreach (var setting in settingsDefinitions)
|
||||
{
|
||||
if (!FilterStrings.Contains(setting.Filter))
|
||||
FilterStrings.Add(setting.Filter);
|
||||
|
||||
foreach (var pair in confSettings)
|
||||
{
|
||||
if (setting.Name == pair.Key)
|
||||
{
|
||||
setting.Value = pair.Value;
|
||||
setting.StartValue = pair.Value;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
switch (setting)
|
||||
{
|
||||
case StringSetting s:
|
||||
var sc = new StringSettingControl(s);
|
||||
sc.TitleTextBox.Foreground = WPF.WPF.ThemeBrush;
|
||||
MainStackPanel.Children.Add(sc);
|
||||
break;
|
||||
case OptionSetting s:
|
||||
var oc = new OptionSettingControl(s);
|
||||
oc.TitleTextBox.Foreground = WPF.WPF.ThemeBrush;
|
||||
MainStackPanel.Children.Add(oc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, string> _Conf;
|
||||
|
||||
public Dictionary<string, string> Conf {
|
||||
get {
|
||||
if (_Conf == null) _Conf = LoadConf(mp.ConfPath);
|
||||
return _Conf;
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, string> _NetConf;
|
||||
|
||||
public Dictionary<string, string> NetConf {
|
||||
get {
|
||||
if (_NetConf == null) _NetConf = LoadConf(App.ConfFilePath);
|
||||
return _NetConf;
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, string> LoadConf(string filePath)
|
||||
{
|
||||
Dictionary<string, string> conf = new Dictionary<string, string>();
|
||||
Comments[filePath] = new Dictionary<string, string>();
|
||||
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
foreach (string i in File.ReadAllLines(filePath))
|
||||
{
|
||||
if (i.Contains("="))
|
||||
{
|
||||
int pos = i.IndexOf("=");
|
||||
string left = i.Substring(0, pos).Replace(" ", "").ToLower();
|
||||
string right = i.Substring(pos + 1).Trim();
|
||||
|
||||
if (left.StartsWith("#"))
|
||||
{
|
||||
Comments[filePath][left.TrimStart('#')] = right;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (left == "fs") left = "fullscreen";
|
||||
if (left == "loop") left = "loop-file";
|
||||
conf[left] = right;
|
||||
}
|
||||
}
|
||||
}
|
||||
return conf;
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
base.OnClosed(e);
|
||||
WriteToDisk();
|
||||
RegistryHelp.SetObject(@"HKCU\Software\mpv.net", "config editor search", SearchControl.Text);
|
||||
}
|
||||
|
||||
void WriteToDisk()
|
||||
{
|
||||
bool isDirty = false;
|
||||
|
||||
foreach (SettingBase i in SettingsDefinitions)
|
||||
if (i.StartValue != i.Value)
|
||||
isDirty = true;
|
||||
|
||||
foreach (SettingBase i in NetSettingsDefinitions)
|
||||
if (i.StartValue != i.Value)
|
||||
isDirty = true;
|
||||
|
||||
if (!isDirty)
|
||||
return;
|
||||
|
||||
WriteToDisk(mp.ConfPath, Conf, SettingsDefinitions);
|
||||
WriteToDisk(App.ConfFilePath, NetConf, NetSettingsDefinitions);
|
||||
|
||||
Msg.Show("Changes will be available on next mpv.net startup.");
|
||||
}
|
||||
|
||||
void WriteToDisk(string filePath,
|
||||
Dictionary<string, string> confSettings,
|
||||
List<SettingBase> settings)
|
||||
{
|
||||
string content = "";
|
||||
|
||||
foreach (var i in Comments[filePath])
|
||||
content += $"#{i.Key} = {i.Value}\r\n";
|
||||
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
if ((setting.Value ?? "") != setting.Default)
|
||||
confSettings[setting.Name] = setting.Value;
|
||||
|
||||
if (confSettings.ContainsKey(setting.Name) &&
|
||||
(setting.Value ?? "") == setting.Default ||
|
||||
(setting.Value ?? "") == "")
|
||||
{
|
||||
confSettings.Remove(setting.Name);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var i in confSettings)
|
||||
content = content + $"{i.Key} = {i.Value}\r\n";
|
||||
|
||||
File.WriteAllText(filePath, content);
|
||||
}
|
||||
|
||||
private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
string activeFilter = "";
|
||||
|
||||
foreach (var i in FilterStrings)
|
||||
if (SearchControl.Text == i + ":")
|
||||
activeFilter = i;
|
||||
|
||||
if (activeFilter == "")
|
||||
{
|
||||
foreach (UIElement i in MainStackPanel.Children)
|
||||
if ((i as ISettingControl).Contains(SearchControl.Text))
|
||||
i.Visibility = Visibility.Visible;
|
||||
else
|
||||
i.Visibility = Visibility.Collapsed;
|
||||
|
||||
FilterListBox.SelectedItem = null;
|
||||
}
|
||||
else
|
||||
foreach (UIElement i in MainStackPanel.Children)
|
||||
if ((i as ISettingControl).SettingBase.Filter == activeFilter)
|
||||
i.Visibility = Visibility.Visible;
|
||||
else
|
||||
i.Visibility = Visibility.Collapsed;
|
||||
|
||||
MainScrollViewer.ScrollToTop();
|
||||
}
|
||||
|
||||
private void ConfWindow1_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SearchControl.SearchTextBox.SelectAll();
|
||||
Keyboard.Focus(SearchControl.SearchTextBox);
|
||||
foreach (var i in MainStackPanel.Children.OfType<StringSettingControl>())
|
||||
i.Update();
|
||||
}
|
||||
|
||||
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (e.AddedItems.Count > 0)
|
||||
SearchControl.Text = e.AddedItems[0].ToString() + ":";
|
||||
}
|
||||
|
||||
private void OpenSettingsTextBlock_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Process.Start(Path.GetDirectoryName(mp.ConfPath));
|
||||
}
|
||||
|
||||
private void ShowManualTextBlock_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Process.Start("https://mpv.io/manual/master/");
|
||||
}
|
||||
|
||||
private void SupportTextBlock_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Process.Start("https://github.com/stax76/mpv.net#Support");
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
if (e.Key == Key.Escape)
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<Window x:Class="mpvnet.EverythingWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Title="Media File Search" Height="300" Width="600" ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterOwner" Loaded="Window_Loaded" FontSize="13">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox Name="FilterTextBox" PreviewKeyDown="FilterTextBox_PreviewKeyDown" TextChanged="FilterTextBox_TextChanged"></TextBox>
|
||||
<ListView Name="ListView" Grid.Row="1" MouseUp="ListView_MouseUp" PreviewKeyDown="ListView_PreviewKeyDown">
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
</ListView>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,44 +0,0 @@
|
||||
<Window xmlns:Controls="clr-namespace:Controls" x:Class="mpvnet.InputWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Title="Input Editor" Height="500" Width="750" FontSize="13"
|
||||
Loaded="Window_Loaded" Closed="Window_Closed" ShowInTaskbar="False">
|
||||
<Window.Resources>
|
||||
<Style x:Key="DataGrid_Font_Centering" TargetType="{x:Type DataGridCell}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type DataGridCell}">
|
||||
<Grid Background="{TemplateBinding Background}">
|
||||
<ContentPresenter VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Controls:SearchTextBoxUserControl HintText="Type ? to get help." x:Name="SearchControl" Width="300" Margin="0,20,0,20" Grid.ColumnSpan="2" />
|
||||
<DataGrid Grid.Row="1" x:Name="DataGrid" CommandManager.PreviewCanExecute="DataGrid_PreviewCanExecute" AutoGenerateColumns="False" CellStyle="{StaticResource DataGrid_Font_Centering}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Menu" Binding="{Binding Path}"/>
|
||||
<DataGridTemplateColumn Header="Input">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Button MinHeight="20" Click="ButtonClick">
|
||||
<TextBlock Text="{Binding Input}"></TextBlock>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Header="Command" Binding="{Binding Command}" MaxWidth="330" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,24 +0,0 @@
|
||||
<Window x:Class="mpvnet.LearnWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Title="Learn Input" Height="200" Width="400" WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="NoResize" Loaded="Window_Loaded" Background="Black" MouseWheel="Window_MouseWheel">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="40" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label x:Name="MenuLabel" Grid.ColumnSpan="2" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="16"></Label>
|
||||
<Label x:Name="KeyLabel" Grid.Row="1" Grid.ColumnSpan="2" Foreground="White" VerticalAlignment="Top" HorizontalAlignment="Center" FontSize="16"></Label>
|
||||
<Button x:Name="ConfirmButton" Grid.Row="2" Click="ConfirmButton_Click">Confirm</Button>
|
||||
<Button x:Name="ClearButton" Grid.Row="2" Click="ClearButton_Click" Grid.Column="1">Clear</Button>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,299 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using WF = System.Windows.Forms;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public partial class LearnWindow : Window
|
||||
{
|
||||
public CommandItem InputItem { get; set; }
|
||||
public string NewKey { get; set; } = "";
|
||||
|
||||
public LearnWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
WF.Message m = new WF.Message();
|
||||
m.HWnd = hwnd;
|
||||
m.Msg = msg;
|
||||
m.WParam = wParam;
|
||||
m.LParam = lParam;
|
||||
ProcessKeyEventArgs(ref m);
|
||||
return m.Result;
|
||||
}
|
||||
|
||||
void OnKeyUp(WF.KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == WF.Keys.ControlKey || e.KeyCode == WF.Keys.ShiftKey ||
|
||||
e.KeyCode == WF.Keys.Menu || e.KeyCode == WF.Keys.None)
|
||||
|
||||
return;
|
||||
|
||||
string text = "";
|
||||
uint charValue = MapVirtualKey((uint)e.KeyCode, 2);
|
||||
|
||||
if (charValue == 0 || (charValue & 1 << 31) == 1 << 31)
|
||||
text = e.KeyCode.ToString().Trim();
|
||||
else
|
||||
try {
|
||||
text = Convert.ToChar(charValue).ToString().ToLower().Trim();
|
||||
}
|
||||
catch {}
|
||||
|
||||
for (int i = 0; i < 13; i++)
|
||||
if ("D" + i.ToString() == text)
|
||||
text = text.Substring(1);
|
||||
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case WF.Keys.NumPad0:
|
||||
case WF.Keys.NumPad1:
|
||||
case WF.Keys.NumPad2:
|
||||
case WF.Keys.NumPad3:
|
||||
case WF.Keys.NumPad4:
|
||||
case WF.Keys.NumPad5:
|
||||
case WF.Keys.NumPad6:
|
||||
case WF.Keys.NumPad7:
|
||||
case WF.Keys.NumPad8:
|
||||
case WF.Keys.NumPad9:
|
||||
text = "KP" + e.KeyCode.ToString()[6].ToString(); break;
|
||||
case WF.Keys.Space:
|
||||
text = "Space"; break;
|
||||
case WF.Keys.Enter:
|
||||
text = "Enter"; break;
|
||||
case WF.Keys.Tab:
|
||||
text = "Tab"; break;
|
||||
case WF.Keys.Back:
|
||||
text = "BS"; break;
|
||||
case WF.Keys.Delete:
|
||||
text = "Del"; break;
|
||||
case WF.Keys.Insert:
|
||||
text = "Ins"; break;
|
||||
case WF.Keys.Home:
|
||||
text = "Home"; break;
|
||||
case WF.Keys.End:
|
||||
text = "End"; break;
|
||||
case WF.Keys.PageUp:
|
||||
text = "PGUP"; break;
|
||||
case WF.Keys.PageDown:
|
||||
text = "PGDWN"; break;
|
||||
case WF.Keys.Escape:
|
||||
text = "Esc"; break;
|
||||
case WF.Keys.PrintScreen:
|
||||
text = "Print"; break;
|
||||
case WF.Keys.Play:
|
||||
text = "Play"; break;
|
||||
case WF.Keys.Pause:
|
||||
text = "Pause"; break;
|
||||
case WF.Keys.MediaPlayPause:
|
||||
text = "PlayPause"; break;
|
||||
case WF.Keys.MediaStop:
|
||||
text = "Stop"; break;
|
||||
case WF.Keys.MediaNextTrack:
|
||||
text = "Next"; break;
|
||||
case WF.Keys.MediaPreviousTrack:
|
||||
text = "Prev"; break;
|
||||
case WF.Keys.VolumeUp:
|
||||
text = "Volume_Up"; break;
|
||||
case WF.Keys.VolumeDown:
|
||||
text = "Volume_Down"; break;
|
||||
case WF.Keys.VolumeMute:
|
||||
text = "Mute"; break;
|
||||
case WF.Keys.BrowserHome:
|
||||
text = "Homepage"; break;
|
||||
case WF.Keys.LaunchMail:
|
||||
text = "Mail"; break;
|
||||
case WF.Keys.BrowserFavorites:
|
||||
text = "Favorites"; break;
|
||||
case WF.Keys.BrowserSearch:
|
||||
text = "Search"; break;
|
||||
case WF.Keys.Sleep:
|
||||
text = "Sleep"; break;
|
||||
case WF.Keys.Cancel:
|
||||
text = "Cancel"; break;
|
||||
}
|
||||
|
||||
bool shiftWasHandled = false;
|
||||
|
||||
bool isAlt = GetKeyState(18) < (short)0;
|
||||
bool isShift = GetKeyState(16) < (short)0;
|
||||
bool isCtrl = GetKeyState(17) < (short)0;
|
||||
|
||||
if (text.Length == 1 && isShift && text[0] != GetModifiedKey(text[0]))
|
||||
{
|
||||
text = GetModifiedKey(text[0]).ToString();
|
||||
shiftWasHandled = true;
|
||||
}
|
||||
|
||||
if (text == "#") text = "Sharp";
|
||||
|
||||
if (isAlt) text = "Alt+" + text;
|
||||
if (isShift && !shiftWasHandled) text = "Shift+" + text;
|
||||
if (isCtrl) text = "Ctrl+" + text;
|
||||
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
SetKey(text);
|
||||
}
|
||||
|
||||
void SetKey(string key)
|
||||
{
|
||||
NewKey = key;
|
||||
MenuLabel.Content = InputItem.Path;
|
||||
KeyLabel.Content = key;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern uint MapVirtualKey(uint uCode, uint uMapType);
|
||||
|
||||
public static WF.Keys ModifierKeys {
|
||||
get {
|
||||
WF.Keys keys = WF.Keys.None;
|
||||
if (GetKeyState(17) < (short)0)
|
||||
keys |= WF.Keys.Control;
|
||||
if (GetKeyState(16) < (short)0)
|
||||
keys |= WF.Keys.Shift;
|
||||
if (GetKeyState(18) < (short)0)
|
||||
keys |= WF.Keys.Alt;
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
|
||||
public static char GetModifiedKey(char c)
|
||||
{
|
||||
short vkKeyScanResult = VkKeyScan(c);
|
||||
|
||||
if (vkKeyScanResult == -1)
|
||||
return c;
|
||||
|
||||
uint code = (uint)vkKeyScanResult & 0xff;
|
||||
byte[] b = new byte[256];
|
||||
b[0x10] = 0x80;
|
||||
uint r;
|
||||
|
||||
if (1 != ToAscii(code, code, b, out r, 0))
|
||||
return c;
|
||||
|
||||
return (char)r;
|
||||
}
|
||||
|
||||
void ProcessKeyEventArgs(ref WF.Message m)
|
||||
{
|
||||
int WM_KEYUP = 0x0101, WM_SYSKEYUP = 0x0105, WM_APPCOMMAND = 0x0319;
|
||||
|
||||
if (m.Msg == WM_KEYUP || m.Msg == WM_SYSKEYUP)
|
||||
OnKeyUp(new WF.KeyEventArgs((WF.Keys)(unchecked((int)(long)m.WParam)) | ModifierKeys));
|
||||
else if (m.Msg == WM_APPCOMMAND)
|
||||
{
|
||||
switch ((AppCommand)(m.LParam.ToInt32() >> 16))
|
||||
{
|
||||
case AppCommand.MEDIA_CHANNEL_DOWN:
|
||||
SetKey("Channel_Down");
|
||||
break;
|
||||
case AppCommand.MEDIA_CHANNEL_UP:
|
||||
SetKey("Channel_Up");
|
||||
break;
|
||||
case AppCommand.MEDIA_FAST_FORWARD:
|
||||
SetKey("Forward");
|
||||
break;
|
||||
case AppCommand.MEDIA_REWIND:
|
||||
SetKey("Rewind");
|
||||
break;
|
||||
case AppCommand.MEDIA_PAUSE:
|
||||
SetKey("Pause");
|
||||
break;
|
||||
case AppCommand.MEDIA_PLAY:
|
||||
SetKey("Play");
|
||||
break;
|
||||
case AppCommand.MEDIA_PLAY_PAUSE:
|
||||
SetKey("PlayPause");
|
||||
break;
|
||||
case AppCommand.MEDIA_NEXTTRACK:
|
||||
SetKey("Next");
|
||||
break;
|
||||
case AppCommand.MEDIA_PREVIOUSTRACK:
|
||||
SetKey("Prev");
|
||||
break;
|
||||
case AppCommand.MEDIA_RECORD:
|
||||
SetKey("Record");
|
||||
break;
|
||||
case AppCommand.MEDIA_STOP:
|
||||
SetKey("Stop");
|
||||
break;
|
||||
case AppCommand.VolumeUp:
|
||||
SetKey("Volume_Up");
|
||||
break;
|
||||
case AppCommand.VolumeDown:
|
||||
SetKey("Volume_Down");
|
||||
break;
|
||||
case AppCommand.VolumeMute:
|
||||
SetKey("Mute");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal enum AppCommand
|
||||
{
|
||||
MEDIA_CHANNEL_DOWN = 52,
|
||||
MEDIA_CHANNEL_UP = 51,
|
||||
MEDIA_FAST_FORWARD = 49,
|
||||
MEDIA_NEXTTRACK = 11,
|
||||
MEDIA_PAUSE = 47,
|
||||
MEDIA_PLAY = 46,
|
||||
MEDIA_PLAY_PAUSE = 14,
|
||||
MEDIA_PREVIOUSTRACK = 12,
|
||||
MEDIA_RECORD = 48,
|
||||
MEDIA_REWIND = 50,
|
||||
MEDIA_STOP = 13,
|
||||
VolumeMute = 8,
|
||||
VolumeDown = 9,
|
||||
VolumeUp = 10
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern short GetKeyState(int keyCode);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern short VkKeyScan(char c);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern int ToAscii(uint uVirtKey,
|
||||
uint uScanCode,
|
||||
byte[] lpKeyState,
|
||||
out uint lpChar,
|
||||
uint flags);
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
|
||||
source.AddHook(new HwndSourceHook(WndProc));
|
||||
SetKey(InputItem.Input);
|
||||
}
|
||||
|
||||
private void ConfirmButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
InputItem.Input = NewKey;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ClearButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
InputItem.Input = "_";
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Window_MouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
if (e.Delta > 0)
|
||||
SetKey("WHEEL_UP");
|
||||
else
|
||||
SetKey("WHEEL_DOWN");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace WPF
|
||||
{
|
||||
public class WPF
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
EnsureApplicationResources();
|
||||
}
|
||||
|
||||
public static void EnsureApplicationResources()
|
||||
{
|
||||
if (Application.Current == null)
|
||||
{
|
||||
new Application();
|
||||
Application.Current.Resources.MergedDictionaries.Add(
|
||||
Application.LoadComponent(new Uri("mpvnet;component/WPF/Resources.xaml",
|
||||
UriKind.Relative)) as ResourceDictionary);
|
||||
}
|
||||
}
|
||||
|
||||
public static Brush ThemeBrush {
|
||||
get {
|
||||
if (Environment.OSVersion.Version.Major < 10)
|
||||
return new SolidColorBrush(Colors.DarkSlateGray);
|
||||
else
|
||||
return SystemParameters.WindowGlassBrush;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,539 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
public static MainForm Instance { get; set; }
|
||||
public static IntPtr Hwnd { get; set; }
|
||||
|
||||
public new ContextMenuStripEx ContextMenu { get; set; }
|
||||
|
||||
Point LastCursorPosChanged;
|
||||
int LastCursorChangedTickCount;
|
||||
bool IgnoreDpiChanged = true;
|
||||
List<string> RecentFiles;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
try
|
||||
{
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
Application.ThreadException += Application_ThreadException;
|
||||
Msg.SupportURL = "https://github.com/stax76/mpv.net#support";
|
||||
Instance = this;
|
||||
WPF.WPF.Init();
|
||||
System.Windows.Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
|
||||
Hwnd = Handle;
|
||||
MinimumSize = new Size(FontHeight * 16, FontHeight * 9);
|
||||
Text += " " + Application.ProductVersion;
|
||||
|
||||
object recent = RegistryHelp.GetObject(App.RegPath, "Recent");
|
||||
|
||||
if (recent is string[] r)
|
||||
RecentFiles = new List<string>(r);
|
||||
else
|
||||
RecentFiles = new List<string>();
|
||||
|
||||
var dummy = mp.Conf;
|
||||
App.ProcessCommandLineEarly();
|
||||
|
||||
if (mp.Screen == -1) mp.Screen = Array.IndexOf(Screen.AllScreens, Screen.PrimaryScreen);
|
||||
SetScreen(mp.Screen);
|
||||
|
||||
ChangeFullscreen(mp.Fullscreen);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Msg.ShowException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
void ContextMenu_Opening(object sender, CancelEventArgs e)
|
||||
{
|
||||
lock (mp.MediaTracks)
|
||||
{
|
||||
MenuItem trackMenuItem = FindMenuItem("Track");
|
||||
|
||||
if (trackMenuItem != null)
|
||||
{
|
||||
trackMenuItem.DropDownItems.Clear();
|
||||
|
||||
MediaTrack[] audTracks = mp.MediaTracks.Where(track => track.Type == "a").ToArray();
|
||||
MediaTrack[] subTracks = mp.MediaTracks.Where(track => track.Type == "s").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)
|
||||
{
|
||||
MenuItem mi = new MenuItem(track.Text);
|
||||
mi.Action = () => { mp.commandv("set", "vid", track.ID.ToString()); };
|
||||
mi.Checked = mp.Vid == track.ID.ToString();
|
||||
trackMenuItem.DropDownItems.Add(mi);
|
||||
}
|
||||
|
||||
if (vidTracks.Length > 0)
|
||||
trackMenuItem.DropDownItems.Add(new ToolStripSeparator());
|
||||
|
||||
foreach (MediaTrack track in audTracks)
|
||||
{
|
||||
MenuItem mi = new MenuItem(track.Text);
|
||||
mi.Action = () => { mp.commandv("set", "aid", track.ID.ToString()); };
|
||||
mi.Checked = mp.Aid == track.ID.ToString();
|
||||
trackMenuItem.DropDownItems.Add(mi);
|
||||
}
|
||||
|
||||
if (subTracks.Length > 0)
|
||||
trackMenuItem.DropDownItems.Add(new ToolStripSeparator());
|
||||
|
||||
foreach (MediaTrack track in subTracks)
|
||||
{
|
||||
MenuItem mi = new MenuItem(track.Text);
|
||||
mi.Action = () => { mp.commandv("set", "sid", track.ID.ToString()); };
|
||||
mi.Checked = mp.Sid == track.ID.ToString();
|
||||
trackMenuItem.DropDownItems.Add(mi);
|
||||
}
|
||||
|
||||
if (subTracks.Length > 0)
|
||||
{
|
||||
MenuItem mi = new MenuItem("S: No subtitles");
|
||||
mi.Action = () => { mp.commandv("set", "sid", "no"); };
|
||||
mi.Checked = mp.Sid == "no";
|
||||
trackMenuItem.DropDownItems.Add(mi);
|
||||
}
|
||||
|
||||
if (ediTracks.Length > 0)
|
||||
trackMenuItem.DropDownItems.Add(new ToolStripSeparator());
|
||||
|
||||
foreach (MediaTrack track in ediTracks)
|
||||
{
|
||||
MenuItem mi = new MenuItem(track.Text);
|
||||
mi.Action = () => { mp.commandv("set", "edition", track.ID.ToString()); };
|
||||
mi.Checked = mp.Edition == track.ID;
|
||||
trackMenuItem.DropDownItems.Add(mi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lock (mp.Chapters)
|
||||
{
|
||||
MenuItem chaptersMenuItem = FindMenuItem("Chapters");
|
||||
|
||||
if (chaptersMenuItem != null)
|
||||
{
|
||||
chaptersMenuItem.DropDownItems.Clear();
|
||||
|
||||
foreach (var i in mp.Chapters)
|
||||
{
|
||||
MenuItem mi = new MenuItem(i.Key);
|
||||
mi.ShortcutKeyDisplayString = TimeSpan.FromSeconds(i.Value).ToString().Substring(0, 8) + " ";
|
||||
mi.Action = () => { mp.commandv("seek", i.Value.ToString(CultureInfo.InvariantCulture), "absolute"); };
|
||||
chaptersMenuItem.DropDownItems.Add(mi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem recent = FindMenuItem("Recent");
|
||||
|
||||
if (recent != null)
|
||||
{
|
||||
recent.DropDownItems.Clear();
|
||||
|
||||
foreach (string path in RecentFiles)
|
||||
MenuItem.Add(recent.DropDownItems, path, () => mp.Load(path));
|
||||
|
||||
recent.DropDownItems.Add(new ToolStripSeparator());
|
||||
MenuItem mi = new MenuItem("Clear List");
|
||||
mi.Action = () => RecentFiles.Clear();
|
||||
recent.DropDownItems.Add(mi);
|
||||
}
|
||||
}
|
||||
|
||||
public MenuItem FindMenuItem(string text) => FindMenuItem(text, ContextMenu.Items);
|
||||
|
||||
MenuItem FindMenuItem(string text, ToolStripItemCollection items)
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item is MenuItem mi)
|
||||
{
|
||||
if (mi.Text.StartsWith(text) && mi.Text.Trim() == text)
|
||||
return mi;
|
||||
if (mi.DropDownItems.Count > 0)
|
||||
{
|
||||
MenuItem val = FindMenuItem(text, mi.DropDownItems);
|
||||
if (val != null) return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void SetScreen(int targetIndex)
|
||||
{
|
||||
Screen[] screens = Screen.AllScreens;
|
||||
if (targetIndex < 0) targetIndex = 0;
|
||||
if (targetIndex > screens.Length - 1) targetIndex = screens.Length - 1;
|
||||
SetScreen(screens[Array.IndexOf(screens, screens[targetIndex])]);
|
||||
}
|
||||
|
||||
protected void SetScreen(Screen screen)
|
||||
{
|
||||
Rectangle target = screen.Bounds;
|
||||
Left = target.X + Convert.ToInt32((target.Width - Width) / 2.0);
|
||||
Top = target.Y + Convert.ToInt32((target.Height - Height) / 2.0);
|
||||
SetStartFormPositionAndSize();
|
||||
}
|
||||
|
||||
void SetStartFormPositionAndSize()
|
||||
{
|
||||
if (IsFullscreen || mp.VideoSize.Width == 0) return;
|
||||
Screen screen = Screen.FromControl(this);
|
||||
int height = Convert.ToInt32(screen.Bounds.Height * mp.Autofit);
|
||||
int width = Convert.ToInt32(height * mp.VideoSize.Width / (double)mp.VideoSize.Height);
|
||||
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
|
||||
var rect = new Native.RECT(new Rectangle(screen.Bounds.X, screen.Bounds.Y, width, height));
|
||||
NativeHelp.AddWindowBorders(Handle, ref rect);
|
||||
int left = middlePos.X - rect.Width / 2;
|
||||
int top = middlePos.Y - rect.Height / 2;
|
||||
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
|
||||
}
|
||||
|
||||
void SetFormPositionAndSizeKeepHeight()
|
||||
{
|
||||
if (IsFullscreen || mp.VideoSize.Width == 0) return;
|
||||
Screen screen = Screen.FromControl(this);
|
||||
int height = ClientSize.Height;
|
||||
if (height > screen.Bounds.Height * 0.9) height = Convert.ToInt32(screen.Bounds.Height * mp.Autofit);
|
||||
int width = Convert.ToInt32(height * mp.VideoSize.Width / (double)mp.VideoSize.Height);
|
||||
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
|
||||
var rect = new Native.RECT(new Rectangle(screen.Bounds.X, screen.Bounds.Y, width, height));
|
||||
NativeHelp.AddWindowBorders(Handle, ref rect);
|
||||
int left = middlePos.X - rect.Width / 2;
|
||||
int top = middlePos.Y - rect.Height / 2;
|
||||
Screen[] screens = Screen.AllScreens;
|
||||
if (left < screens[0].Bounds.Left) left = screens[0].Bounds.Left;
|
||||
int maxLeft = screens[0].Bounds.Left + screens.Select((sc) => sc.Bounds.Width).Sum() - rect.Width - SystemInformation.CaptionHeight;
|
||||
if (left > maxLeft) left = maxLeft;
|
||||
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
|
||||
}
|
||||
|
||||
public void BuildMenu()
|
||||
{
|
||||
string content = File.ReadAllText(mp.InputConfPath);
|
||||
var items = CommandItem.GetItems(content);
|
||||
|
||||
if (!content.Contains("#menu:"))
|
||||
{
|
||||
var defaultItems = CommandItem.GetItems(Properties.Resources.inputConf);
|
||||
foreach (CommandItem item in items)
|
||||
foreach (CommandItem defaultItem in defaultItems)
|
||||
if (item.Command == defaultItem.Command)
|
||||
defaultItem.Input = item.Input;
|
||||
items = defaultItems;
|
||||
}
|
||||
|
||||
foreach (CommandItem item in items)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.Path))
|
||||
continue;
|
||||
string path = item.Path.Replace("&", "&&");
|
||||
MenuItem menuItem = ContextMenu.Add(path, () => {
|
||||
try {
|
||||
mp.command_string(item.Command);
|
||||
} catch (Exception ex) {
|
||||
Msg.ShowException(ex);
|
||||
}
|
||||
});
|
||||
if (menuItem != null)
|
||||
menuItem.ShortcutKeyDisplayString = item.Input + " ";
|
||||
}
|
||||
}
|
||||
|
||||
void ContextMenu_Opened(object sender, EventArgs e) => CursorHelp.Show();
|
||||
|
||||
private void Mp_FileLoaded()
|
||||
{
|
||||
string path = mp.get_property_string("path");
|
||||
BeginInvoke(new Action(() => {
|
||||
if (File.Exists(path) || path.StartsWith("http"))
|
||||
Text = Path.GetFileName(path) + " - mpv.net " + Application.ProductVersion;
|
||||
else
|
||||
Text = "mpv.net " + Application.ProductVersion;
|
||||
}));
|
||||
if (RecentFiles.Contains(path)) RecentFiles.Remove(path);
|
||||
RecentFiles.Insert(0, path);
|
||||
if (RecentFiles.Count > 15) RecentFiles.RemoveAt(15);
|
||||
}
|
||||
|
||||
void Mp_Idle() => BeginInvoke(new Action(() => { Text = "mpv.net " + Application.ProductVersion; }));
|
||||
|
||||
void CM_Popup(object sender, EventArgs e) => CursorHelp.Show();
|
||||
|
||||
void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
|
||||
{
|
||||
Msg.ShowException(e.Exception);
|
||||
}
|
||||
|
||||
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
Msg.ShowError(e.ExceptionObject.ToString());
|
||||
}
|
||||
|
||||
void mp_VideoSizeChanged()
|
||||
{
|
||||
BeginInvoke(new Action(() => SetFormPositionAndSizeKeepHeight()));
|
||||
}
|
||||
|
||||
void mp_Shutdown()
|
||||
{
|
||||
BeginInvoke(new Action(() => Close()));
|
||||
}
|
||||
|
||||
public bool IsFullscreen => WindowState == FormWindowState.Maximized;
|
||||
|
||||
void mpPropChangeFullscreen(bool value)
|
||||
{
|
||||
BeginInvoke(new Action(() => ChangeFullscreen(value)));
|
||||
}
|
||||
|
||||
void ChangeFullscreen(bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
if (FormBorderStyle != FormBorderStyle.None)
|
||||
{
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
WindowState = FormWindowState.Maximized;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowState = FormWindowState.Normal;
|
||||
FormBorderStyle = FormBorderStyle.Sizable;
|
||||
SetFormPositionAndSizeKeepHeight();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
//Debug.WriteLine(m);
|
||||
|
||||
switch (m.Msg)
|
||||
{
|
||||
case 0x0201: // WM_LBUTTONDOWN
|
||||
case 0x0202: // WM_LBUTTONUP
|
||||
case 0x0100: // WM_KEYDOWN
|
||||
case 0x0101: // WM_KEYUP
|
||||
case 0x0104: // WM_SYSKEYDOWN
|
||||
case 0x0105: // WM_SYSKEYUP
|
||||
case 0x020A: // WM_MOUSEWHEEL
|
||||
if (mp.WindowHandle != IntPtr.Zero)
|
||||
Native.SendMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
|
||||
break;
|
||||
case 0x0200: // WM_MOUSEMOVE
|
||||
Point pos = PointToClient(Cursor.Position);
|
||||
mp.command_string($"mouse {pos.X} {pos.Y}");
|
||||
if (CursorHelp.IsPosDifferent(LastCursorPosChanged)) CursorHelp.Show();
|
||||
break;
|
||||
case 0x319: // WM_APPCOMMAND
|
||||
if (mp.WindowHandle != IntPtr.Zero)
|
||||
Native.PostMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
|
||||
break;
|
||||
case 0x203: // Native.WM.LBUTTONDBLCLK
|
||||
if (!IsMouseInOSC())
|
||||
mp.command_string("cycle fullscreen");
|
||||
break;
|
||||
case 0x02E0: // WM_DPICHANGED
|
||||
if (IgnoreDpiChanged) break;
|
||||
var r2 = Marshal.PtrToStructure<Native.RECT>(m.LParam);
|
||||
Native.SetWindowPos(Handle, IntPtr.Zero, r2.Left, r2.Top, r2.Width, r2.Height, 0);
|
||||
break;
|
||||
case 0x0214: // WM_SIZING
|
||||
var rc = Marshal.PtrToStructure<Native.RECT>(m.LParam);
|
||||
var r = rc;
|
||||
NativeHelp.SubtractWindowBorders(Handle, ref r);
|
||||
int c_w = r.Right - r.Left, c_h = r.Bottom - r.Top;
|
||||
float aspect = mp.VideoSize.Width / (float)mp.VideoSize.Height;
|
||||
int d_w = Convert.ToInt32(c_h * aspect - c_w);
|
||||
int d_h = Convert.ToInt32(c_w / aspect - c_h);
|
||||
int[] d_corners = { d_w, d_h, -d_w, -d_h };
|
||||
int[] corners = { rc.Left, rc.Top, rc.Right, rc.Bottom };
|
||||
int corner = NativeHelp.GetResizeBorder(m.WParam.ToInt32());
|
||||
|
||||
if (corner >= 0)
|
||||
corners[corner] -= d_corners[corner];
|
||||
|
||||
Marshal.StructureToPtr<Native.RECT>(new Native.RECT(corners[0], corners[1], corners[2], corners[3]), m.LParam, false);
|
||||
m.Result = new IntPtr(1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m.Msg == SingleProcess.Message)
|
||||
{
|
||||
object filesObject = RegistryHelp.GetObject(App.RegPath, "ShellFiles");
|
||||
|
||||
if (filesObject is string[] files)
|
||||
{
|
||||
switch (RegistryHelp.GetString(App.RegPath, "ProcessInstanceMode"))
|
||||
{
|
||||
case "single":
|
||||
mp.Load(files);
|
||||
break;
|
||||
case "queue":
|
||||
foreach (string file in files)
|
||||
mp.commandv("loadfile", file, "append");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RegistryHelp.RemoveValue(App.RegPath, "ShellFiles");
|
||||
Activate();
|
||||
return;
|
||||
}
|
||||
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
protected override void OnDragEnter(DragEventArgs e)
|
||||
{
|
||||
base.OnDragEnter(e);
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop) || e.Data.GetDataPresent(DataFormats.Text))
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
|
||||
protected override void OnDragDrop(DragEventArgs e)
|
||||
{
|
||||
base.OnDragDrop(e);
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
mp.Load(e.Data.GetData(DataFormats.FileDrop) as String[]);
|
||||
if (e.Data.GetDataPresent(DataFormats.Text))
|
||||
mp.Load(e.Data.GetData(DataFormats.Text).ToString());
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
if (WindowState == FormWindowState.Normal &&
|
||||
e.Button == MouseButtons.Left &&
|
||||
e.Y < ClientSize.Height * 0.9)
|
||||
{
|
||||
var HTCAPTION = new IntPtr(2);
|
||||
Native.ReleaseCapture();
|
||||
Native.PostMessage(Handle, 0xA1 /* WM_NCLBUTTONDOWN */, HTCAPTION, IntPtr.Zero);
|
||||
}
|
||||
|
||||
if (Width - e.Location.X < 10 && e.Location.Y < 10)
|
||||
mp.commandv("quit");
|
||||
}
|
||||
|
||||
bool IsMouseInOSC() => PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9;
|
||||
|
||||
void Timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
|
||||
{
|
||||
LastCursorPosChanged = Control.MousePosition;
|
||||
LastCursorChangedTickCount = Environment.TickCount;
|
||||
}
|
||||
else if (Environment.TickCount - LastCursorChangedTickCount > 1500 &&
|
||||
!IsMouseInOSC() && ClientRectangle.Contains(PointToClient(MousePosition)) &&
|
||||
Form.ActiveForm == this && !ContextMenu.Visible)
|
||||
{
|
||||
CursorHelp.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
mp.Init();
|
||||
mp.observe_property_bool("fullscreen", mpPropChangeFullscreen);
|
||||
mp.observe_property_bool("ontop", mpPropChangeOnTop);
|
||||
mp.observe_property_string("sid", mpPropChangeSid);
|
||||
mp.observe_property_string("aid", mpPropChangeAid);
|
||||
mp.observe_property_string("vid", mpPropChangeVid);
|
||||
mp.observe_property_int("edition", mpPropChangeEdition);
|
||||
mp.Shutdown += mp_Shutdown;
|
||||
mp.VideoSizeChanged += mp_VideoSizeChanged;
|
||||
mp.FileLoaded += Mp_FileLoaded;
|
||||
mp.Idle += Mp_Idle;
|
||||
}
|
||||
|
||||
void mpPropChangeOnTop(bool value) => BeginInvoke(new Action(() => TopMost = value));
|
||||
|
||||
void mpPropChangeAid(string value) => mp.Aid = value;
|
||||
|
||||
void mpPropChangeSid(string value) => mp.Sid = value;
|
||||
|
||||
void mpPropChangeVid(string value) => mp.Vid = value;
|
||||
|
||||
void mpPropChangeEdition(int value) => mp.Edition = value;
|
||||
|
||||
protected override void OnShown(EventArgs e)
|
||||
{
|
||||
base.OnShown(e);
|
||||
if (App.IsDarkMode) ToolStripRendererEx.ColorTheme = Color.Black;
|
||||
ContextMenu = new ContextMenuStripEx(components);
|
||||
ContextMenu.Opened += ContextMenu_Opened;
|
||||
ContextMenu.Opening += ContextMenu_Opening;
|
||||
BuildMenu();
|
||||
ContextMenuStrip = ContextMenu;
|
||||
IgnoreDpiChanged = false;
|
||||
CheckURLinClipboard();
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
if (mp.IsLogoVisible) mp.ShowLogo();
|
||||
}
|
||||
|
||||
protected override void OnFormClosed(FormClosedEventArgs e)
|
||||
{
|
||||
base.OnFormClosed(e);
|
||||
RegistryHelp.SetObject(App.RegPath, "Recent", RecentFiles.ToArray());
|
||||
mp.commandv("quit");
|
||||
mp.AutoResetEvent.WaitOne(3000);
|
||||
}
|
||||
|
||||
protected override void OnLostFocus(EventArgs e)
|
||||
{
|
||||
base.OnLostFocus(e);
|
||||
CursorHelp.Show();
|
||||
}
|
||||
|
||||
protected override void OnActivated(EventArgs e)
|
||||
{
|
||||
base.OnActivated(e);
|
||||
CheckURLinClipboard();
|
||||
}
|
||||
|
||||
void CheckURLinClipboard()
|
||||
{
|
||||
if (App.ClipboardMonitoring != "yes") return;
|
||||
string clipboard = Clipboard.GetText();
|
||||
|
||||
if (clipboard.StartsWith("http") && RegistryHelp.GetString(App.RegPath, "LastURL") != clipboard && Visible)
|
||||
{
|
||||
RegistryHelp.SetObject(App.RegPath, "LastURL", clipboard);
|
||||
|
||||
if (Msg.ShowQuestion("Play URL?", clipboard) == MsgResult.OK)
|
||||
mp.Load(clipboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,187 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class libmpv
|
||||
{
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr mpv_create();
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int mpv_initialize(IntPtr mpvHandle);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int mpv_command(IntPtr mpvHandle, IntPtr strings);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int mpv_command_string(IntPtr mpvHandle, [MarshalAs(UnmanagedType.LPUTF8Str)] string command);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int mpv_terminate_destroy(IntPtr mpvHandle);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int mpv_set_option(IntPtr mpvHandle, byte[] name, mpv_format format, ref long data);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int mpv_set_option_string(IntPtr mpvHandle, byte[] name, byte[] value);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int mpv_get_property(IntPtr mpvHandle, byte[] name, mpv_format format, out IntPtr data);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int mpv_get_property(IntPtr mpvHandle, byte[] name, mpv_format format, ref double data);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int mpv_set_property(IntPtr mpvHandle, byte[] name, mpv_format format, ref byte[] data);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int mpv_set_property(IntPtr mpvHandle, byte[] name, mpv_format format, ref Int64 data);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int mpv_observe_property(
|
||||
IntPtr mpvHandle,
|
||||
UInt64 reply_userdata,
|
||||
[MarshalAs(UnmanagedType.LPUTF8Str)] string name,
|
||||
mpv_format format);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int mpv_unobserve_property(IntPtr mpvHandle, UInt64 registered_reply_userdata);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void mpv_free(IntPtr data);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr mpv_wait_event(IntPtr mpvHandle, double timeout);
|
||||
|
||||
public enum mpv_error
|
||||
{
|
||||
MPV_ERROR_SUCCESS = 0,
|
||||
MPV_ERROR_EVENT_QUEUE_FULL = -1,
|
||||
MPV_ERROR_NOMEM = -2,
|
||||
MPV_ERROR_UNINITIALIZED = -3,
|
||||
MPV_ERROR_INVALID_PARAMETER = -4,
|
||||
MPV_ERROR_OPTION_NOT_FOUND = -5,
|
||||
MPV_ERROR_OPTION_FORMAT = -6,
|
||||
MPV_ERROR_OPTION_ERROR = -7,
|
||||
MPV_ERROR_PROPERTY_NOT_FOUND = -8,
|
||||
MPV_ERROR_PROPERTY_FORMAT = -9,
|
||||
MPV_ERROR_PROPERTY_UNAVAILABLE = -10,
|
||||
MPV_ERROR_PROPERTY_ERROR = -11,
|
||||
MPV_ERROR_COMMAND = -12,
|
||||
MPV_ERROR_LOADING_FAILED = -13,
|
||||
MPV_ERROR_AO_INIT_FAILED = -14,
|
||||
MPV_ERROR_VO_INIT_FAILED = -15,
|
||||
MPV_ERROR_NOTHING_TO_PLAY = -16,
|
||||
MPV_ERROR_UNKNOWN_FORMAT = -17,
|
||||
MPV_ERROR_UNSUPPORTED = -18,
|
||||
MPV_ERROR_NOT_IMPLEMENTED = -19,
|
||||
MPV_ERROR_GENERIC = -20
|
||||
}
|
||||
|
||||
public enum mpv_event_id
|
||||
{
|
||||
MPV_EVENT_NONE = 0,
|
||||
MPV_EVENT_SHUTDOWN = 1,
|
||||
MPV_EVENT_LOG_MESSAGE = 2,
|
||||
MPV_EVENT_GET_PROPERTY_REPLY = 3,
|
||||
MPV_EVENT_SET_PROPERTY_REPLY = 4,
|
||||
MPV_EVENT_COMMAND_REPLY = 5,
|
||||
MPV_EVENT_START_FILE = 6,
|
||||
MPV_EVENT_END_FILE = 7,
|
||||
MPV_EVENT_FILE_LOADED = 8,
|
||||
MPV_EVENT_TRACKS_CHANGED = 9,
|
||||
MPV_EVENT_TRACK_SWITCHED = 10,
|
||||
MPV_EVENT_IDLE = 11,
|
||||
MPV_EVENT_PAUSE = 12,
|
||||
MPV_EVENT_UNPAUSE = 13,
|
||||
MPV_EVENT_TICK = 14,
|
||||
MPV_EVENT_SCRIPT_INPUT_DISPATCH = 15,
|
||||
MPV_EVENT_CLIENT_MESSAGE = 16,
|
||||
MPV_EVENT_VIDEO_RECONFIG = 17,
|
||||
MPV_EVENT_AUDIO_RECONFIG = 18,
|
||||
MPV_EVENT_METADATA_UPDATE = 19,
|
||||
MPV_EVENT_SEEK = 20,
|
||||
MPV_EVENT_PLAYBACK_RESTART = 21,
|
||||
MPV_EVENT_PROPERTY_CHANGE = 22,
|
||||
MPV_EVENT_CHAPTER_CHANGE = 23,
|
||||
MPV_EVENT_QUEUE_OVERFLOW = 24,
|
||||
MPV_EVENT_HOOK = 25
|
||||
}
|
||||
|
||||
public enum mpv_format
|
||||
{
|
||||
MPV_FORMAT_NONE = 0,
|
||||
MPV_FORMAT_STRING = 1,
|
||||
MPV_FORMAT_OSD_STRING = 2,
|
||||
MPV_FORMAT_FLAG = 3,
|
||||
MPV_FORMAT_INT64 = 4,
|
||||
MPV_FORMAT_DOUBLE = 5,
|
||||
MPV_FORMAT_NODE = 6,
|
||||
MPV_FORMAT_NODE_ARRAY = 7,
|
||||
MPV_FORMAT_NODE_MAP = 8,
|
||||
MPV_FORMAT_BYTE_ARRAY = 9
|
||||
}
|
||||
|
||||
public enum mpv_log_level
|
||||
{
|
||||
MPV_LOG_LEVEL_NONE = 0,
|
||||
MPV_LOG_LEVEL_FATAL = 10,
|
||||
MPV_LOG_LEVEL_ERROR = 20,
|
||||
MPV_LOG_LEVEL_WARN = 30,
|
||||
MPV_LOG_LEVEL_INFO = 40,
|
||||
MPV_LOG_LEVEL_V = 50,
|
||||
MPV_LOG_LEVEL_DEBUG = 60,
|
||||
MPV_LOG_LEVEL_TRACE = 70,
|
||||
}
|
||||
|
||||
public enum mpv_end_file_reason
|
||||
{
|
||||
MPV_END_FILE_REASON_EOF = 0,
|
||||
MPV_END_FILE_REASON_STOP = 2,
|
||||
MPV_END_FILE_REASON_QUIT = 3,
|
||||
MPV_END_FILE_REASON_ERROR = 4,
|
||||
MPV_END_FILE_REASON_REDIRECT = 5
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct mpv_event_log_message
|
||||
{
|
||||
public string prefix;
|
||||
public string level;
|
||||
public string text;
|
||||
public mpv_log_level log_level;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct mpv_event
|
||||
{
|
||||
public mpv_event_id event_id;
|
||||
public int error;
|
||||
public UInt64 reply_userdata;
|
||||
public IntPtr data;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct mpv_event_client_message
|
||||
{
|
||||
public int num_args;
|
||||
public IntPtr args;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct mpv_event_property
|
||||
{
|
||||
public string name;
|
||||
public mpv_format format;
|
||||
public IntPtr data;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct mpv_event_end_file
|
||||
{
|
||||
public int reason;
|
||||
public int error;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,824 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using static mpvnet.libmpv;
|
||||
using static mpvnet.Native;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public delegate void MpvBoolPropChangeHandler(string propName, bool value);
|
||||
|
||||
public class mp
|
||||
{
|
||||
public static event Action VideoSizeChanged;
|
||||
// Lua/JS event libmpv event
|
||||
|
||||
// MPV_EVENT_NONE
|
||||
public static event Action Shutdown; // shutdown MPV_EVENT_SHUTDOWN
|
||||
public static event Action LogMessage; // log-message MPV_EVENT_LOG_MESSAGE
|
||||
public static event Action GetPropertyReply; // get-property-reply MPV_EVENT_GET_PROPERTY_REPLY
|
||||
public static event Action SetPropertyReply; // set-property-reply MPV_EVENT_SET_PROPERTY_REPLY
|
||||
public static event Action CommandReply; // command-reply MPV_EVENT_COMMAND_REPLY
|
||||
public static event Action StartFile; // start-file MPV_EVENT_START_FILE
|
||||
public static event Action<EndFileEventMode> EndFile; // end-file MPV_EVENT_END_FILE
|
||||
public static event Action FileLoaded; // file-loaded MPV_EVENT_FILE_LOADED
|
||||
public static event Action TracksChanged; // MPV_EVENT_TRACKS_CHANGED
|
||||
public static event Action TrackSwitched; // MPV_EVENT_TRACK_SWITCHED
|
||||
public static event Action Idle; // idle MPV_EVENT_IDLE
|
||||
public static event Action Pause; // MPV_EVENT_PAUSE
|
||||
public static event Action Unpause; // MPV_EVENT_UNPAUSE
|
||||
public static event Action Tick; // tick MPV_EVENT_TICK
|
||||
public static event Action ScriptInputDispatch; // MPV_EVENT_SCRIPT_INPUT_DISPATCH
|
||||
public static event Action<string[]> ClientMessage; // client-message MPV_EVENT_CLIENT_MESSAGE
|
||||
public static event Action VideoReconfig; // video-reconfig MPV_EVENT_VIDEO_RECONFIG
|
||||
public static event Action AudioReconfig; // audio-reconfig MPV_EVENT_AUDIO_RECONFIG
|
||||
public static event Action MetadataUpdate; // MPV_EVENT_METADATA_UPDATE
|
||||
public static event Action Seek; // seek MPV_EVENT_SEEK
|
||||
public static event Action PlaybackRestart; // playback-restart MPV_EVENT_PLAYBACK_RESTART
|
||||
// MPV_EVENT_PROPERTY_CHANGE
|
||||
public static event Action ChapterChange; // MPV_EVENT_CHAPTER_CHANGE
|
||||
public static event Action QueueOverflow; // MPV_EVENT_QUEUE_OVERFLOW
|
||||
public static event Action Hook; // MPV_EVENT_HOOK
|
||||
|
||||
public static IntPtr Handle { get; set; }
|
||||
public static IntPtr WindowHandle { get; set; }
|
||||
public static Addon Addon { get; set; }
|
||||
public static bool IsLogoVisible { set; get; }
|
||||
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 Size VideoSize { get; set; } = new Size(1920, 1080);
|
||||
public static List<PythonScript> PythonScripts { get; set; } = new List<PythonScript>();
|
||||
public static AutoResetEvent AutoResetEvent { get; set; } = new AutoResetEvent(false);
|
||||
public static List<MediaTrack> MediaTracks { get; set; } = new List<MediaTrack>();
|
||||
public static List<KeyValuePair<string, double>> Chapters { get; set; } = new List<KeyValuePair<string, double>>();
|
||||
|
||||
public static string InputConfPath { get; } = ConfFolder + "\\input.conf";
|
||||
public static string ConfPath { get; } = ConfFolder + "\\mpv.conf";
|
||||
|
||||
public static bool Fullscreen { get; set; }
|
||||
public static float Autofit { get; set; } = 0.50f;
|
||||
public static int Screen { get; set; } = -1;
|
||||
public static string Sid { get; set; } = "";
|
||||
public static string Aid { get; set; } = "";
|
||||
public static string Vid { get; set; } = "";
|
||||
public static int Edition { get; set; }
|
||||
|
||||
static string _ConfFolder;
|
||||
|
||||
public static string ConfFolder {
|
||||
get {
|
||||
if (_ConfFolder == null)
|
||||
{
|
||||
string portableFolder = Application.StartupPath + "\\portable_config\\";
|
||||
string appdataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\";
|
||||
string startupFolder = Application.StartupPath + "\\";
|
||||
|
||||
if (!Directory.Exists(appdataFolder) && !Directory.Exists(portableFolder) &&
|
||||
Sys.IsDirectoryWritable(Application.StartupPath) &&
|
||||
!File.Exists(startupFolder + "mpv.conf"))
|
||||
{
|
||||
using (TaskDialog<string> td = new TaskDialog<string>())
|
||||
{
|
||||
td.MainInstruction = "Choose a settings folder.";
|
||||
td.Content = "[MPV documentation about files on Windows.](https://mpv.io/manual/master/#files-on-windows)";
|
||||
td.AddCommandLink("appdata", appdataFolder, appdataFolder);
|
||||
td.AddCommandLink("portable", portableFolder, portableFolder);
|
||||
td.AddCommandLink("startup", startupFolder, startupFolder);
|
||||
td.AllowCancel = false;
|
||||
_ConfFolder = td.Show();
|
||||
}
|
||||
}
|
||||
else if (Directory.Exists(portableFolder))
|
||||
_ConfFolder = portableFolder;
|
||||
else if (Directory.Exists(appdataFolder))
|
||||
_ConfFolder = appdataFolder;
|
||||
else if (File.Exists(Application.StartupPath + "\\mpv.conf"))
|
||||
_ConfFolder = Application.StartupPath + "\\";
|
||||
|
||||
if (string.IsNullOrEmpty(_ConfFolder)) _ConfFolder = appdataFolder;
|
||||
if (!Directory.Exists(_ConfFolder)) Directory.CreateDirectory(_ConfFolder);
|
||||
|
||||
if (!File.Exists(_ConfFolder + "\\input.conf"))
|
||||
File.WriteAllText(_ConfFolder + "\\input.conf", Properties.Resources.inputConf);
|
||||
|
||||
if (!File.Exists(_ConfFolder + "\\mpv.conf"))
|
||||
File.WriteAllText(_ConfFolder + "\\mpv.conf", Properties.Resources.mpvConf);
|
||||
}
|
||||
return _ConfFolder;
|
||||
}
|
||||
}
|
||||
|
||||
static Dictionary<string, string> _Conf;
|
||||
|
||||
public static Dictionary<string, string> Conf {
|
||||
get {
|
||||
if (_Conf == null)
|
||||
{
|
||||
_Conf = new Dictionary<string, string>();
|
||||
|
||||
if (File.Exists(ConfPath))
|
||||
foreach (var i in File.ReadAllLines(ConfPath))
|
||||
if (i.Contains("=") && ! i.StartsWith("#"))
|
||||
_Conf[i.Substring(0, i.IndexOf("=")).Trim()] = i.Substring(i.IndexOf("=") + 1).Trim();
|
||||
|
||||
foreach (var i in Conf)
|
||||
ProcessProperty(i.Key, i.Value);
|
||||
}
|
||||
return _Conf;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
string dummy = ConfFolder;
|
||||
LoadLibrary("mpv-1.dll");
|
||||
Handle = mpv_create();
|
||||
set_property_string("input-default-bindings", "yes");
|
||||
set_property_string("osc", "yes");
|
||||
set_property_string("config", "yes");
|
||||
set_property_string("wid", MainForm.Hwnd.ToString());
|
||||
set_property_string("force-window", "yes");
|
||||
set_property_string("input-media-keys", "yes");
|
||||
mpv_initialize(Handle);
|
||||
ShowLogo();
|
||||
ProcessCommandLine();
|
||||
Task.Run(() => { LoadScripts(); });
|
||||
Task.Run(() => { Addon = new Addon(); });
|
||||
Task.Run(() => { EventLoop(); });
|
||||
}
|
||||
|
||||
public static void LoadScripts()
|
||||
{
|
||||
string[] jsLua = { ".lua", ".js" };
|
||||
string[] startupScripts = Directory.GetFiles(Application.StartupPath + "\\Scripts");
|
||||
|
||||
foreach (var scriptPath in startupScripts)
|
||||
if (jsLua.Contains(Path.GetExtension(scriptPath).ToLower()))
|
||||
mp.commandv("load-script", $"{scriptPath}");
|
||||
|
||||
foreach (var scriptPath in startupScripts)
|
||||
if (Path.GetExtension(scriptPath) == ".py")
|
||||
PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath)));
|
||||
|
||||
foreach (var scriptPath in startupScripts)
|
||||
if (Path.GetExtension(scriptPath) == ".ps1")
|
||||
PowerShellScript.Init(scriptPath);
|
||||
|
||||
if (Directory.Exists(mp.ConfFolder + "Scripts"))
|
||||
foreach (var scriptPath in Directory.GetFiles(mp.ConfFolder + "Scripts"))
|
||||
if (Path.GetExtension(scriptPath) == ".py")
|
||||
PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath)));
|
||||
else if (Path.GetExtension(scriptPath) == ".ps1")
|
||||
PowerShellScript.Init(scriptPath);
|
||||
}
|
||||
|
||||
public static void EventLoop()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
IntPtr ptr = mpv_wait_event(Handle, -1);
|
||||
mpv_event evt = (mpv_event)Marshal.PtrToStructure(ptr, typeof(mpv_event));
|
||||
|
||||
if (WindowHandle == IntPtr.Zero)
|
||||
{
|
||||
WindowHandle = FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null);
|
||||
//Native.EnableWindow(WindowHandle, true);
|
||||
}
|
||||
|
||||
//Debug.WriteLine(evt.event_id.ToString());
|
||||
|
||||
try
|
||||
{
|
||||
switch (evt.event_id)
|
||||
{
|
||||
case mpv_event_id.MPV_EVENT_SHUTDOWN:
|
||||
Shutdown?.Invoke();
|
||||
WriteHistory(null);
|
||||
AutoResetEvent.Set();
|
||||
return;
|
||||
case mpv_event_id.MPV_EVENT_LOG_MESSAGE:
|
||||
LogMessage?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_GET_PROPERTY_REPLY:
|
||||
GetPropertyReply?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_SET_PROPERTY_REPLY:
|
||||
SetPropertyReply?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_COMMAND_REPLY:
|
||||
CommandReply?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_START_FILE:
|
||||
StartFile?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_END_FILE:
|
||||
var end_fileData = (mpv_event_end_file)Marshal.PtrToStructure(evt.data, typeof(mpv_event_end_file));
|
||||
EndFileEventMode reason = (EndFileEventMode)end_fileData.reason;
|
||||
EndFile?.Invoke(reason);
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_FILE_LOADED:
|
||||
HideLogo();
|
||||
FileLoaded?.Invoke();
|
||||
WriteHistory(mp.get_property_string("path"));
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_TRACKS_CHANGED:
|
||||
TracksChanged?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_TRACK_SWITCHED:
|
||||
TrackSwitched?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_IDLE:
|
||||
Idle?.Invoke();
|
||||
if (mp.get_property_int("playlist-count") == 0)
|
||||
ShowLogo();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_PAUSE:
|
||||
Pause?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_UNPAUSE:
|
||||
Unpause?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_TICK:
|
||||
Tick?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_SCRIPT_INPUT_DISPATCH:
|
||||
ScriptInputDispatch?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_CLIENT_MESSAGE:
|
||||
var client_messageData = (mpv_event_client_message)Marshal.PtrToStructure(evt.data, typeof(mpv_event_client_message));
|
||||
string[] args = NativeUtf8StrArray2ManagedStrArray(client_messageData.args, client_messageData.num_args);
|
||||
|
||||
if (args != null && args.Length > 1 && args[0] == "mpv.net")
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
foreach (var i in mpvnet.Command.Commands)
|
||||
{
|
||||
if (args[1] == i.Name)
|
||||
{
|
||||
found = true;
|
||||
i.Action.Invoke(args.Skip(2).ToArray());
|
||||
MainForm.Instance.BeginInvoke(new Action(() => {
|
||||
Message m = new Message() { Msg = 0x0202 }; // WM_LBUTTONUP
|
||||
Native.SendMessage(MainForm.Instance.Handle, m.Msg, m.WParam, m.LParam);
|
||||
}));
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
List<string> names = mpvnet.Command.Commands.Select((item) => item.Name).ToList();
|
||||
names.Sort();
|
||||
Msg.ShowError($"No command '{args[1]}' found.", $"Available commands are:\n\n{string.Join("\n", names)}\n\nHow to bind these commands can be seen in the [default input bindings and menu definition](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt).");
|
||||
}
|
||||
}
|
||||
ClientMessage?.Invoke(args);
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_VIDEO_RECONFIG:
|
||||
VideoReconfig?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_AUDIO_RECONFIG:
|
||||
AudioReconfig?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_METADATA_UPDATE:
|
||||
MetadataUpdate?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_SEEK:
|
||||
Seek?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_PROPERTY_CHANGE:
|
||||
var propData = (mpv_event_property)Marshal.PtrToStructure(evt.data, typeof(mpv_event_property));
|
||||
|
||||
if (propData.format == mpv_format.MPV_FORMAT_FLAG)
|
||||
foreach (var i in BoolPropChangeActions)
|
||||
if (i.Key== propData.name)
|
||||
i.Value.Invoke(Marshal.PtrToStructure<int>(propData.data) == 1);
|
||||
|
||||
if (propData.format == mpv_format.MPV_FORMAT_STRING)
|
||||
foreach (var i in StringPropChangeActions)
|
||||
if (i.Key == propData.name)
|
||||
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;
|
||||
case mpv_event_id.MPV_EVENT_PLAYBACK_RESTART:
|
||||
PlaybackRestart?.Invoke();
|
||||
Size vidSize = new Size(get_property_int("dwidth"), get_property_int("dheight"));
|
||||
|
||||
if (VideoSize != vidSize && vidSize != Size.Empty)
|
||||
{
|
||||
VideoSize = vidSize;
|
||||
VideoSizeChanged?.Invoke();
|
||||
}
|
||||
|
||||
Task.Run(new Action(() => ReadMetaData()));
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_CHAPTER_CHANGE:
|
||||
ChapterChange?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_QUEUE_OVERFLOW:
|
||||
QueueOverflow?.Invoke();
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_HOOK:
|
||||
Hook?.Invoke();
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Msg.ShowException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void HideLogo()
|
||||
{
|
||||
if (IsLogoVisible)
|
||||
{
|
||||
mp.commandv("overlay-remove", "0");
|
||||
IsLogoVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
static List<PythonEventObject> PythonEventObjects = new List<PythonEventObject>();
|
||||
|
||||
public static void register_event(string name, IronPython.Runtime.PythonFunction pyFunc)
|
||||
{
|
||||
foreach (var eventInfo in typeof(mp).GetEvents())
|
||||
{
|
||||
if (eventInfo.Name.ToLower() == name.Replace("-", ""))
|
||||
{
|
||||
PythonEventObject eventObject = new PythonEventObject();
|
||||
PythonEventObjects.Add(eventObject);
|
||||
eventObject.PythonFunction = pyFunc;
|
||||
MethodInfo mi;
|
||||
|
||||
if (eventInfo.EventHandlerType == typeof(Action))
|
||||
{
|
||||
mi = eventObject.GetType().GetMethod(nameof(PythonEventObject.Invoke));
|
||||
}
|
||||
else if (eventInfo.EventHandlerType == typeof(Action<EndFileEventMode>))
|
||||
{
|
||||
mi = eventObject.GetType().GetMethod(nameof(PythonEventObject.InvokeEndFileEventMode));
|
||||
}
|
||||
else if (eventInfo.EventHandlerType == typeof(Action<string[]>))
|
||||
{
|
||||
mi = eventObject.GetType().GetMethod(nameof(PythonEventObject.InvokeStrings));
|
||||
}
|
||||
else
|
||||
throw new Exception();
|
||||
|
||||
eventObject.EventInfo = eventInfo;
|
||||
Delegate handler = Delegate.CreateDelegate(eventInfo.EventHandlerType, eventObject, mi);
|
||||
eventObject.Delegate = handler;
|
||||
eventInfo.AddEventHandler(eventObject, handler);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void unregister_event(IronPython.Runtime.PythonFunction pyFunc)
|
||||
{
|
||||
foreach (var eventObjects in PythonEventObjects)
|
||||
if (eventObjects.PythonFunction == pyFunc)
|
||||
eventObjects.EventInfo.RemoveEventHandler(eventObjects, eventObjects.Delegate);
|
||||
}
|
||||
|
||||
public static void commandv(params string[] args)
|
||||
{
|
||||
if (Handle == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
IntPtr mainPtr = AllocateUtf8IntPtrArrayWithSentinel(args, out IntPtr[] byteArrayPointers);
|
||||
int err = mpv_command(Handle, mainPtr);
|
||||
|
||||
if (err < 0)
|
||||
throw new Exception($"{(mpv_error)err}");
|
||||
|
||||
foreach (var ptr in byteArrayPointers)
|
||||
Marshal.FreeHGlobal(ptr);
|
||||
|
||||
Marshal.FreeHGlobal(mainPtr);
|
||||
}
|
||||
|
||||
public static void command_string(string command, bool throwException = false)
|
||||
{
|
||||
if (Handle == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
int err = mpv_command_string(Handle, command);
|
||||
|
||||
if (err < 0 && throwException)
|
||||
throw new Exception($"{(mpv_error)err}\r\n\r\n" + command);
|
||||
}
|
||||
|
||||
public static void set_property_string(string name, string value, bool throwOnException = false)
|
||||
{
|
||||
byte[] bytes = GetUtf8Bytes(value);
|
||||
int err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, ref bytes);
|
||||
|
||||
if (err < 0 && throwOnException)
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
}
|
||||
|
||||
public static string get_property_string(string name, bool throwOnException = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
int err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, out IntPtr lpBuffer);
|
||||
|
||||
if (err < 0 && throwOnException)
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
|
||||
string ret = StringFromNativeUtf8(lpBuffer);
|
||||
mpv_free(lpBuffer);
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (throwOnException) throw ex;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static int get_property_int(string name, bool throwOnException = false)
|
||||
{
|
||||
int err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, out IntPtr lpBuffer);
|
||||
|
||||
if (err < 0 && throwOnException)
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
else
|
||||
return lpBuffer.ToInt32();
|
||||
}
|
||||
|
||||
public static double get_property_number(string name, bool throwOnException = false)
|
||||
{
|
||||
double val = 0;
|
||||
int err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_DOUBLE, ref val);
|
||||
|
||||
if (err < 0 && throwOnException)
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
else
|
||||
return val;
|
||||
}
|
||||
|
||||
public static bool get_property_bool(string name, bool throwOnException = false)
|
||||
{
|
||||
int err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_FLAG, out IntPtr lpBuffer);
|
||||
|
||||
if (err < 0 && throwOnException)
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
else
|
||||
return lpBuffer.ToInt32() == 1;
|
||||
}
|
||||
|
||||
public static void set_property_int(string name, int value, bool throwOnException = false)
|
||||
{
|
||||
Int64 val = value;
|
||||
int err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref val);
|
||||
|
||||
if (err < 0 && throwOnException)
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
}
|
||||
|
||||
public static void observe_property_int(string name, Action<int> action)
|
||||
{
|
||||
int err = mpv_observe_property(Handle, (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)
|
||||
{
|
||||
int err = mpv_observe_property(Handle, (ulong)action.GetHashCode(), name, mpv_format.MPV_FORMAT_FLAG);
|
||||
|
||||
if (err < 0)
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
else
|
||||
BoolPropChangeActions.Add(new KeyValuePair<string, Action<bool>>(name, action));
|
||||
}
|
||||
|
||||
public static void observe_property_string(string name, Action<string> action)
|
||||
{
|
||||
int err = mpv_observe_property(Handle, (ulong)action.GetHashCode(), name, mpv_format.MPV_FORMAT_STRING);
|
||||
|
||||
if (err < 0)
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
else
|
||||
StringPropChangeActions.Add(new KeyValuePair<string, Action<string>>(name, action));
|
||||
}
|
||||
|
||||
protected static void ProcessCommandLine()
|
||||
{
|
||||
var args = Environment.GetCommandLineArgs().Skip(1);
|
||||
List<string> files = new List<string>();
|
||||
|
||||
foreach (string i in args)
|
||||
{
|
||||
if (!i.StartsWith("--") && (File.Exists(i) || i == "-" || i.StartsWith("http")))
|
||||
{
|
||||
files.Add(i);
|
||||
if (i.StartsWith("http"))
|
||||
RegistryHelp.SetObject(App.RegPath, "LastURL", i);
|
||||
}
|
||||
}
|
||||
|
||||
mp.Load(files.ToArray());
|
||||
|
||||
foreach (string i in args)
|
||||
{
|
||||
if (i.StartsWith("--"))
|
||||
{
|
||||
if (i.Contains("="))
|
||||
{
|
||||
string left = i.Substring(2, i.IndexOf("=") - 2);
|
||||
string right = i.Substring(left.Length + 3);
|
||||
mp.set_property_string(left, right);
|
||||
}
|
||||
else
|
||||
mp.set_property_string(i.Substring(2), "yes");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Load(params string[] files)
|
||||
{
|
||||
if (files is null || files.Length == 0) return;
|
||||
HideLogo();
|
||||
List<string> fileList = files.ToList();
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
string ext = Path.GetExtension(file).TrimStart('.').ToLower();
|
||||
|
||||
if (App.SubtitleTypes.Contains(ext))
|
||||
{
|
||||
mp.commandv("sub-add", file);
|
||||
fileList.Remove(file);
|
||||
}
|
||||
}
|
||||
|
||||
if (fileList.Count == 0) return;
|
||||
files = fileList.ToArray();
|
||||
|
||||
int count = mp.get_property_int("playlist-count");
|
||||
|
||||
foreach (string file in files)
|
||||
mp.commandv("loadfile", file, "append");
|
||||
|
||||
mp.set_property_int("playlist-pos", count);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
mp.commandv("playlist-remove", "0");
|
||||
|
||||
mp.LoadFolder(files[0]);
|
||||
}
|
||||
|
||||
static void LoadFolder(string path)
|
||||
{
|
||||
if (get_property_int("playlist-count") == 1)
|
||||
{
|
||||
if (!File.Exists(path)) return;
|
||||
List<string> files = Directory.GetFiles(Path.GetDirectoryName(path)).ToList();
|
||||
files = files.Where((file) => App.VideoTypes.Contains(Path.GetExtension(file).TrimStart('.').ToLower()) ||
|
||||
App.AudioTypes.Contains(Path.GetExtension(file).TrimStart('.').ToLower())).ToList();
|
||||
files.Sort(new StringLogicalComparer());
|
||||
int index = files.IndexOf(path);
|
||||
files.Remove(path);
|
||||
foreach (string i in files)
|
||||
commandv("loadfile", i, "append");
|
||||
if (index > 0)
|
||||
commandv("playlist-move", "0", (index + 1).ToString());
|
||||
}
|
||||
}
|
||||
|
||||
static IntPtr AllocateUtf8IntPtrArrayWithSentinel(string[] arr, out IntPtr[] byteArrayPointers)
|
||||
{
|
||||
int numberOfStrings = arr.Length + 1; // add extra element for extra null pointer last (sentinel)
|
||||
byteArrayPointers = new IntPtr[numberOfStrings];
|
||||
IntPtr rootPointer = Marshal.AllocCoTaskMem(IntPtr.Size * numberOfStrings);
|
||||
|
||||
for (int index = 0; index < arr.Length; index++)
|
||||
{
|
||||
var bytes = GetUtf8Bytes(arr[index]);
|
||||
IntPtr unmanagedPointer = Marshal.AllocHGlobal(bytes.Length);
|
||||
Marshal.Copy(bytes, 0, unmanagedPointer, bytes.Length);
|
||||
byteArrayPointers[index] = unmanagedPointer;
|
||||
}
|
||||
|
||||
Marshal.Copy(byteArrayPointers, 0, rootPointer, numberOfStrings);
|
||||
return rootPointer;
|
||||
}
|
||||
|
||||
static string[] NativeUtf8StrArray2ManagedStrArray(IntPtr pUnmanagedStringArray, int StringCount)
|
||||
{
|
||||
IntPtr[] pIntPtrArray = new IntPtr[StringCount];
|
||||
string[] ManagedStringArray = new string[StringCount];
|
||||
Marshal.Copy(pUnmanagedStringArray, pIntPtrArray, 0, StringCount);
|
||||
|
||||
for (int i = 0; i < StringCount; i++)
|
||||
ManagedStringArray[i] = StringFromNativeUtf8(pIntPtrArray[i]);
|
||||
|
||||
return ManagedStringArray;
|
||||
}
|
||||
|
||||
static string StringFromNativeUtf8(IntPtr nativeUtf8)
|
||||
{
|
||||
int len = 0;
|
||||
while (Marshal.ReadByte(nativeUtf8, len) != 0) ++len;
|
||||
byte[] buffer = new byte[len];
|
||||
Marshal.Copy(nativeUtf8, buffer, 0, buffer.Length);
|
||||
return Encoding.UTF8.GetString(buffer);
|
||||
}
|
||||
|
||||
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.ConfFolder + "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;
|
||||
}
|
||||
|
||||
public static void ShowLogo()
|
||||
{
|
||||
if (MainForm.Instance is null) return;
|
||||
Rectangle cr = MainForm.Instance.ClientRectangle;
|
||||
if (cr.Width == 0 || cr.Height == 0) return;
|
||||
|
||||
using (Bitmap b = new Bitmap(cr.Width, cr.Height))
|
||||
{
|
||||
using (Graphics g = Graphics.FromImage(b))
|
||||
{
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
g.Clear(Color.Black);
|
||||
int iconWidth = cr.Height / 7;
|
||||
Rectangle r = new Rectangle(cr.Width / 2 - iconWidth / 2, cr.Height / 2 - iconWidth / 2, iconWidth, iconWidth);
|
||||
g.DrawImage(Properties.Resources.mpvnet, r);
|
||||
BitmapData bd = b.LockBits(cr, ImageLockMode.ReadOnly, PixelFormat.Format32bppPArgb);
|
||||
mp.commandv("overlay-add", "0", "0", "0", "&" + bd.Scan0.ToInt64().ToString(), "0", "bgra", bd.Width.ToString(), bd.Height.ToString(), bd.Stride.ToString());
|
||||
b.UnlockBits(bd);
|
||||
IsLogoVisible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ProcessProperty(string name, string value)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "autofit":
|
||||
if (value.Length == 3 && value.EndsWith("%"))
|
||||
if (int.TryParse(value.Substring(0, 2), out int result))
|
||||
mp.Autofit = result / 100f;
|
||||
break;
|
||||
case "fs":
|
||||
case "fullscreen":
|
||||
mp.Fullscreen = value == "yes";
|
||||
break;
|
||||
case "screen":
|
||||
mp.Screen = Convert.ToInt32(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void ReadMetaData()
|
||||
{
|
||||
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(' ', ',');
|
||||
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(' ', ',');
|
||||
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(' ', ',');
|
||||
track.Type = "s";
|
||||
track.ID = i + 1;
|
||||
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)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(val) && !(track.Text != null && track.Text.Contains(val)))
|
||||
track.Text += " " + val + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum EndFileEventMode
|
||||
{
|
||||
Eof,
|
||||
Stop,
|
||||
Quit,
|
||||
Error,
|
||||
Redirect,
|
||||
Unknown
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 24 KiB |
44
setup.iss
@@ -1,44 +0,0 @@
|
||||
#define MyAppName "mpv.net"
|
||||
#define MyAppExeName "mpvnet.exe"
|
||||
|
||||
#ifndef arch
|
||||
#define arch "x64"
|
||||
#endif
|
||||
|
||||
#if arch == "x64"
|
||||
#define MyAppSourceDir "mpv.net\bin\x64"
|
||||
#define MyAppVersion GetFileVersion("mpv.net\bin\x64\mpvnet.exe")
|
||||
#else
|
||||
#define MyAppSourceDir "mpv.net\bin\x86"
|
||||
#define MyAppVersion GetFileVersion("mpv.net\bin\x86\mpvnet.exe")
|
||||
#endif
|
||||
|
||||
[Setup]
|
||||
AppId={{9AA2B100-BEF3-44D0-B819-D8FC3C4D557D}}
|
||||
AppName={#MyAppName}
|
||||
AppVersion={#MyAppVersion}
|
||||
AppPublisher=Frank Skare (stax76)
|
||||
#if arch == "x64"
|
||||
ArchitecturesInstallIn64BitMode=x64
|
||||
#endif
|
||||
Compression=lzma2
|
||||
DefaultDirName={commonpf}\{#MyAppName}
|
||||
OutputBaseFilename=mpv.net-setup-{#arch}-{#MyAppVersion}
|
||||
OutputDir={#GetEnv('USERPROFILE')}\Desktop
|
||||
DefaultGroupName={#MyAppName}
|
||||
SetupIconFile=mpv.net\mpvnet.ico
|
||||
UninstallDisplayIcon={app}\{#MyAppExeName}
|
||||
|
||||
[Icons]
|
||||
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||||
|
||||
[Files]
|
||||
Source: "{#MyAppSourceDir}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#MyAppSourceDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Excludes: "System.Management.Automation.xml"
|
||||
|
||||
[Run]
|
||||
Filename: "{app}\{#MyAppExeName}"; Description: "Associate video file extensions?"; Flags: postinstall unchecked runascurrentuser runhidden nowait; Parameters: "--reg-file-assoc video"
|
||||
Filename: "{app}\{#MyAppExeName}"; Description: "Associate audio file extensions?"; Flags: postinstall unchecked runascurrentuser runhidden nowait; Parameters: "--reg-file-assoc audio"
|
||||
|
||||
[UninstallRun]
|
||||
Filename: "{app}\{#MyAppExeName}"; Flags: runascurrentuser runhidden; Parameters: "--reg-file-assoc unreg"
|
||||
48
setup.ps1
@@ -1,48 +0,0 @@
|
||||
# exit the script if the exit code is greater than 0
|
||||
function CheckExitCode {
|
||||
if ($LastExitCode -gt 0) {
|
||||
Write-Host "`nExit code $LastExitCode was returned.`n" -ForegroundColor Red
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
# exit the script if the file don't exist
|
||||
function CheckFileExist($path) {
|
||||
if (![IO.File]::Exists($path)) {
|
||||
Write-Host "`nFile is missing:`n`n$path`n" -ForegroundColor Red
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
$msbuild = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe"
|
||||
$innoSetup = "C:\Program Files (x86)\Inno Setup 6\ISCC.exe"
|
||||
$sevenZip = "C:\Program Files\7-Zip\7z.exe"
|
||||
|
||||
# exit the script if one of the executables don't exist
|
||||
CheckFileExist($msbuild); CheckFileExist($innoSetup); CheckFileExist($sevenZip);
|
||||
|
||||
# build the projects using msbuild
|
||||
& $msbuild mpv.net.sln /p:Configuration=Debug /p:Platform=x64; CheckExitCode
|
||||
& $msbuild mpv.net.sln /p:Configuration=Debug /p:Platform=x86; CheckExitCode
|
||||
|
||||
# build the setups using inno setup
|
||||
& $innoSetup /Darch="x64" setup.iss; CheckExitCode
|
||||
& $innoSetup /Darch="x86" setup.iss; CheckExitCode
|
||||
|
||||
# create the x64 portable archives using 7zip
|
||||
$scriptDir = Split-Path -Path $PSCommandPath -Parent
|
||||
$desktopDir = [Environment]::GetFolderPath("Desktop")
|
||||
$exePath = $scriptDir + "\mpv.net\bin\x64\mpvnet.exe"
|
||||
$version = [Diagnostics.FileVersionInfo]::GetVersionInfo($exePath).FileVersion
|
||||
$targetDir = $desktopDir + "\mpv.net-portable-x64-" + $version
|
||||
Copy-Item $scriptDir\mpv.net\bin\x64 $targetDir -Recurse -Exclude System.Management.Automation.xml -Force
|
||||
& $sevenZip a -t7z -mx9 "$targetDir.7z" -r "$targetDir\*"; CheckExitCode
|
||||
& $sevenZip a -tzip -mx9 "$targetDir.zip" -r "$targetDir\*"; CheckExitCode
|
||||
|
||||
# create the x86 portable archives using 7zip
|
||||
$exePath = $scriptDir + "\mpv.net\bin\x86\mpvnet.exe"
|
||||
$version = [Diagnostics.FileVersionInfo]::GetVersionInfo($exePath).FileVersion
|
||||
$targetDir = $desktopDir + "\mpv.net-portable-x86-" + $version
|
||||
Copy-Item $scriptDir\mpv.net\bin\x86 $targetDir -Recurse -Exclude System.Management.Automation.xml -Force
|
||||
& $sevenZip a -t7z -mx9 "$targetDir.7z" -r "$targetDir\*"; CheckExitCode
|
||||
& $sevenZip a -tzip -mx9 "$targetDir.zip" -r "$targetDir\*"; CheckExitCode
|
||||
@@ -3,6 +3,6 @@
|
||||
<configSections>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
</configuration>
|
||||
@@ -1,12 +1,13 @@
|
||||
using System;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
using Tommy;
|
||||
using mpvnet;
|
||||
|
||||
namespace DynamicGUI
|
||||
{
|
||||
@@ -15,8 +16,10 @@ namespace DynamicGUI
|
||||
public static List<SettingBase> LoadSettings(string content)
|
||||
{
|
||||
TomlTable table;
|
||||
|
||||
using (StringReader reader = new StringReader(content))
|
||||
table = TOML.Parse(reader);
|
||||
|
||||
List<SettingBase> settingsList = new List<SettingBase>();
|
||||
|
||||
foreach (TomlTable setting in table["settings"])
|
||||
@@ -29,36 +32,39 @@ namespace DynamicGUI
|
||||
baseSetting = optionSetting;
|
||||
optionSetting.Default = setting["default"];
|
||||
optionSetting.Value = optionSetting.Default;
|
||||
optionSetting.StartValue = optionSetting.Default;
|
||||
|
||||
foreach (TomlTable option in setting["options"])
|
||||
{
|
||||
var opt = new OptionSettingOption();
|
||||
opt.Name = option["name"];
|
||||
|
||||
if (option.HasKey("help"))
|
||||
opt.Help = option["help"];
|
||||
|
||||
if (option.HasKey("text"))
|
||||
opt.Text = option["text"];
|
||||
else if (opt.Name == optionSetting.Default)
|
||||
opt.Text = opt.Name + " (Default)";
|
||||
|
||||
opt.OptionSetting = optionSetting;
|
||||
optionSetting.Options.Add(opt);
|
||||
}
|
||||
}
|
||||
else if (setting["default"].IsString)
|
||||
else
|
||||
{
|
||||
StringSetting stringSetting = new StringSetting();
|
||||
baseSetting = stringSetting;
|
||||
stringSetting.Default = setting["default"];
|
||||
stringSetting.Default = setting.HasKey("default") ? setting["default"].ToString() : "";
|
||||
}
|
||||
|
||||
baseSetting.Name = setting["name"];
|
||||
baseSetting.File = setting["file"];
|
||||
baseSetting.Filter = setting["filter"];
|
||||
|
||||
if (setting.HasKey("help")) baseSetting.Help = setting["help"];
|
||||
if (setting.HasKey("helpurl")) baseSetting.HelpURL = setting["helpurl"];
|
||||
if (setting.HasKey("help")) baseSetting.Help = setting["help"];
|
||||
if (setting.HasKey("url")) baseSetting.URL = setting["url"];
|
||||
if (setting.HasKey("width")) baseSetting.Width = setting["width"];
|
||||
if (setting.HasKey("type")) baseSetting.Type = setting["type"];
|
||||
if (setting.HasKey("type")) baseSetting.Type = setting["type"];
|
||||
|
||||
settingsList.Add(baseSetting);
|
||||
}
|
||||
@@ -66,17 +72,33 @@ namespace DynamicGUI
|
||||
}
|
||||
}
|
||||
|
||||
public class ConfItem
|
||||
{
|
||||
public string Comment { get; set; } = "";
|
||||
public string File { get; set; } = "";
|
||||
public string LineComment { get; set; } = "";
|
||||
public string Name { get; set; } = "";
|
||||
public string Section { get; set; } = "";
|
||||
public string Value { get; set; } = "";
|
||||
|
||||
public bool IsSectionItem { get; set; }
|
||||
public SettingBase SettingBase { get; set; }
|
||||
}
|
||||
|
||||
public abstract class SettingBase
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
public string StartValue { get; set; }
|
||||
public string Help { get; set; }
|
||||
public string Default { get; set; }
|
||||
public string HelpURL { get; set; }
|
||||
public string File { get; set; }
|
||||
public string Filter { get; set; }
|
||||
public string Help { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string StartValue { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string URL { get; set; }
|
||||
public string Value { get; set; }
|
||||
|
||||
public int Width { get; set; }
|
||||
public ConfItem ConfItem { get; set; }
|
||||
}
|
||||
|
||||
public class StringSetting : SettingBase
|
||||
@@ -95,7 +117,7 @@ namespace DynamicGUI
|
||||
|
||||
public OptionSetting OptionSetting { get; set; }
|
||||
|
||||
private string _Text;
|
||||
string _Text;
|
||||
|
||||
public string Text
|
||||
{
|
||||
@@ -106,7 +128,10 @@ namespace DynamicGUI
|
||||
public bool Checked
|
||||
{
|
||||
get => OptionSetting.Value == Name ;
|
||||
set { if (value) OptionSetting.Value = Name; }
|
||||
set {
|
||||
if (value)
|
||||
OptionSetting.Value = Name;
|
||||
}
|
||||
}
|
||||
|
||||
public Visibility Visibility
|
||||
@@ -123,9 +148,9 @@ namespace DynamicGUI
|
||||
|
||||
public class HyperlinkEx : Hyperlink
|
||||
{
|
||||
private void HyperLinkEx_RequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||
void HyperLinkEx_RequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
Process.Start(e.Uri.AbsoluteUri);
|
||||
ProcessHelp.ShellExecute(e.Uri.AbsoluteUri);
|
||||
}
|
||||
|
||||
public void SetURL(string url)
|
||||
73
src/DynamicGUI/OptionSettingControl.xaml
Normal file
@@ -0,0 +1,73 @@
|
||||
<UserControl
|
||||
x:Name="OptionSettingControl1" x:Class="DynamicGUI.OptionSettingControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DynamicGUI"
|
||||
mc:Ignorable="d"
|
||||
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<Grid Margin="20,0">
|
||||
<StackPanel>
|
||||
<TextBox
|
||||
x:Name="TitleTextBox"
|
||||
FontSize="24"
|
||||
Margin="0,10"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Foreground="{Binding Theme.Heading}"
|
||||
Background="{Binding Theme.Background}"
|
||||
/>
|
||||
|
||||
<ItemsControl x:Name="ItemsControl">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<WrapPanel Orientation="Vertical">
|
||||
<RadioButton
|
||||
x:Name="RadioButton"
|
||||
VerticalContentAlignment="Center"
|
||||
IsChecked="{Binding Checked}"
|
||||
GroupName="{Binding OptionSetting.Name}"
|
||||
Content="{Binding Text}"
|
||||
FontSize="16"
|
||||
FontWeight="Normal"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Theme.Foreground}"
|
||||
/>
|
||||
|
||||
<TextBox
|
||||
x:Name="ItemHelpTextBox"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
Text="{Binding Help}"
|
||||
Visibility="{Binding Visibility}"
|
||||
Margin="10,0,0,0" BorderThickness="0"
|
||||
IsReadOnly="True" Padding="7,0,0,0"
|
||||
MinHeight="0"
|
||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Theme.Foreground2}"
|
||||
Background="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Theme.Background}"
|
||||
/>
|
||||
|
||||
</WrapPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<TextBox
|
||||
x:Name="HelpTextBox"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Margin="0,10,0,0"
|
||||
Foreground="{Binding Theme.Foreground}"
|
||||
Background="{Binding Theme.Background}"
|
||||
/>
|
||||
|
||||
<TextBlock x:Name="LinkTextBlock" Margin="0,10">
|
||||
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,35 +1,49 @@
|
||||
using System.Windows;
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
using mpvnet;
|
||||
|
||||
namespace DynamicGUI
|
||||
{
|
||||
public partial class OptionSettingControl : UserControl, ISettingControl
|
||||
{
|
||||
private OptionSetting OptionSetting;
|
||||
OptionSetting OptionSetting;
|
||||
|
||||
public OptionSettingControl(OptionSetting optionSetting)
|
||||
{
|
||||
OptionSetting = optionSetting;
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
TitleTextBox.Text = optionSetting.Name;
|
||||
|
||||
if (string.IsNullOrEmpty(optionSetting.Help))
|
||||
HelpTextBox.Visibility = Visibility.Collapsed;
|
||||
|
||||
HelpTextBox.Text = optionSetting.Help;
|
||||
ItemsControl.ItemsSource = optionSetting.Options;
|
||||
if (string.IsNullOrEmpty(optionSetting.HelpURL))
|
||||
|
||||
if (string.IsNullOrEmpty(optionSetting.URL))
|
||||
LinkTextBlock.Visibility = Visibility.Collapsed;
|
||||
Link.SetURL(optionSetting.HelpURL);
|
||||
|
||||
Link.SetURL(optionSetting.URL);
|
||||
}
|
||||
|
||||
private string _SearchableText;
|
||||
public Theme Theme {
|
||||
get => Theme.Current;
|
||||
}
|
||||
|
||||
string _SearchableText;
|
||||
|
||||
public string SearchableText {
|
||||
get {
|
||||
if (_SearchableText is null)
|
||||
{
|
||||
_SearchableText = TitleTextBox.Text + HelpTextBox.Text;
|
||||
|
||||
foreach (var i in OptionSetting.Options)
|
||||
_SearchableText += i.Text + i.Help + i.Name;
|
||||
|
||||
_SearchableText = _SearchableText.ToLower();
|
||||
}
|
||||
return _SearchableText;
|
||||
@@ -39,4 +53,4 @@ namespace DynamicGUI
|
||||
public SettingBase SettingBase => OptionSetting;
|
||||
public bool Contains(string searchString) => SearchableText.Contains(searchString.ToLower());
|
||||
}
|
||||
}
|
||||
}
|
||||
65
src/DynamicGUI/StringSettingControl.xaml
Normal file
@@ -0,0 +1,65 @@
|
||||
<UserControl
|
||||
x:Name="StringSettingControl1" x:Class="DynamicGUI.StringSettingControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DynamicGUI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<Grid Margin="20,0">
|
||||
<StackPanel>
|
||||
<TextBox
|
||||
x:Name="TitleTextBox"
|
||||
FontSize="24"
|
||||
Margin="0,10"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Foreground="{Binding Theme.Heading}"
|
||||
Background="{Binding Theme.Background}"
|
||||
/>
|
||||
|
||||
<Grid Margin="0,0,0,10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox
|
||||
x:Name="ValueTextBox"
|
||||
Text="{Binding Path=Text, ElementName=StringSettingControl1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Width="150"
|
||||
Height="20"
|
||||
HorizontalAlignment="Left"
|
||||
Foreground="{Binding Theme.Foreground}"
|
||||
Background="{Binding Theme.Background}"
|
||||
CaretBrush="{Binding Theme.Foreground}"
|
||||
TextChanged="ValueTextBox_TextChanged"
|
||||
/>
|
||||
|
||||
<Button
|
||||
x:Name="Button"
|
||||
Height="20"
|
||||
Grid.Column="1"
|
||||
Margin="5,0,0,0"
|
||||
Width="20"
|
||||
Click="Button_Click"
|
||||
>...</Button>
|
||||
</Grid>
|
||||
|
||||
<TextBox
|
||||
x:Name="HelpTextBox"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Foreground="{Binding Theme.Foreground}"
|
||||
Background="{Binding Theme.Background}"
|
||||
/>
|
||||
|
||||
<TextBlock x:Name="LinkTextBlock" Margin="0,10">
|
||||
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,38 +1,51 @@
|
||||
using System;
|
||||
|
||||
using mpvnet;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
using WinForms = System.Windows.Forms;
|
||||
|
||||
namespace DynamicGUI
|
||||
{
|
||||
public partial class StringSettingControl : UserControl, ISettingControl
|
||||
{
|
||||
private StringSetting StringSetting;
|
||||
StringSetting StringSetting;
|
||||
|
||||
public StringSettingControl(StringSetting stringSetting)
|
||||
{
|
||||
StringSetting = stringSetting;
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
TitleTextBox.Text = stringSetting.Name;
|
||||
HelpTextBox.Text = stringSetting.Help;
|
||||
ValueTextBox.Text = StringSetting.Value;
|
||||
|
||||
if (StringSetting.Width > 0)
|
||||
ValueTextBox.Width = StringSetting.Width;
|
||||
|
||||
if (StringSetting.Type != "folder" && StringSetting.Type != "color")
|
||||
Button.Visibility = Visibility.Hidden;
|
||||
Link.SetURL(StringSetting.HelpURL);
|
||||
if (string.IsNullOrEmpty(stringSetting.HelpURL))
|
||||
|
||||
Link.SetURL(StringSetting.URL);
|
||||
|
||||
if (string.IsNullOrEmpty(stringSetting.URL))
|
||||
LinkTextBlock.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private string _SearchableText;
|
||||
public Theme Theme {
|
||||
get => Theme.Current;
|
||||
}
|
||||
|
||||
string _SearchableText;
|
||||
|
||||
public string SearchableText {
|
||||
get {
|
||||
if (_SearchableText is null)
|
||||
_SearchableText = (TitleTextBox.Text + HelpTextBox.Text +ValueTextBox.Text).ToLower();
|
||||
|
||||
return _SearchableText;
|
||||
}
|
||||
}
|
||||
@@ -46,7 +59,7 @@ namespace DynamicGUI
|
||||
set => StringSetting.Value = value;
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
switch (StringSetting.Type)
|
||||
{
|
||||
@@ -55,49 +68,62 @@ namespace DynamicGUI
|
||||
{
|
||||
d.Description = "Choose a folder.";
|
||||
d.SelectedPath = ValueTextBox.Text;
|
||||
if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
|
||||
if (d.ShowDialog() == WinForms.DialogResult.OK)
|
||||
ValueTextBox.Text = d.SelectedPath;
|
||||
}
|
||||
break;
|
||||
case "color":
|
||||
using (var d = new WinForms.ColorDialog())
|
||||
using (var dialog = new WinForms.ColorDialog())
|
||||
{
|
||||
d.FullOpen = true;
|
||||
try {
|
||||
d.Color = System.Drawing.ColorTranslator.FromHtml(ValueTextBox.Text);
|
||||
} catch { }
|
||||
if (d.ShowDialog() == WinForms.DialogResult.OK)
|
||||
ValueTextBox.Text = System.Drawing.ColorTranslator.ToHtml(d.Color);
|
||||
dialog.FullOpen = true;
|
||||
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ValueTextBox.Text))
|
||||
{
|
||||
Color col = GetColor(ValueTextBox.Text);
|
||||
dialog.Color = System.Drawing.Color.FromArgb(col.A, col.R, col.G, col.B);
|
||||
}
|
||||
} catch {}
|
||||
|
||||
if (dialog.ShowDialog() == WinForms.DialogResult.OK)
|
||||
ValueTextBox.Text = "#" + dialog.Color.ToArgb().ToString("X8");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ValueTextBox_TextChanged(object sender, TextChangedEventArgs e) => Update();
|
||||
void ValueTextBox_TextChanged(object sender, TextChangedEventArgs e) => Update();
|
||||
|
||||
Color GetColor(string value)
|
||||
{
|
||||
if (value.Contains("/"))
|
||||
{
|
||||
string[] a = value.Split('/');
|
||||
|
||||
if (a.Length == 3)
|
||||
return Color.FromRgb(ToByte(a[0]), ToByte(a[1]), ToByte(a[2]));
|
||||
else if (a.Length == 4)
|
||||
return Color.FromArgb(ToByte(a[3]), ToByte(a[0]), ToByte(a[1]), ToByte(a[2]));
|
||||
}
|
||||
|
||||
return (Color)ColorConverter.ConvertFromString(value);
|
||||
|
||||
Byte ToByte(string val) => Convert.ToByte(Convert.ToSingle(val, CultureInfo.InvariantCulture) * 255);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (StringSetting.Type == "color")
|
||||
{
|
||||
Color c = Colors.Transparent;
|
||||
|
||||
if (ValueTextBox.Text != "")
|
||||
{
|
||||
try {
|
||||
if (ValueTextBox.Text.Contains("/"))
|
||||
{
|
||||
string[] a = ValueTextBox.Text.Split('/');
|
||||
if (a.Length == 3)
|
||||
c = Color.FromRgb(ToByte(a[0]), ToByte(a[1]), ToByte(a[2]));
|
||||
else if (a.Length == 4)
|
||||
c = Color.FromArgb(ToByte(a[3]), ToByte(a[0]), ToByte(a[1]), ToByte(a[2]));
|
||||
}
|
||||
else
|
||||
c = (Color)ColorConverter.ConvertFromString(ValueTextBox.Text);
|
||||
} catch {}
|
||||
}
|
||||
try { c = GetColor(ValueTextBox.Text); } catch {}
|
||||
|
||||
ValueTextBox.Background = new SolidColorBrush(c);
|
||||
}
|
||||
Byte ToByte(string val) => Convert.ToByte(Convert.ToSingle(val, CultureInfo.InvariantCulture) * 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -381,7 +381,8 @@ namespace Tommy
|
||||
|
||||
public override TomlNode this[string key] {
|
||||
get {
|
||||
if (RawTable.TryGetValue(key, out var result)) return result;
|
||||
if (RawTable.TryGetValue(key, out var result))
|
||||
return result;
|
||||
|
||||
var lazy = new TomlLazy(this);
|
||||
RawTable[key] = lazy;
|
||||
@@ -1752,7 +1753,6 @@ namespace Tommy
|
||||
}
|
||||
else
|
||||
stringBuilder.Append(c);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("RatingAddon")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyTitle("RatingExtension")]
|
||||
[assembly: AssemblyDescription("RatingExtension")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("RatingAddon")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyCompany("Frank Skare (stax76)")]
|
||||
[assembly: AssemblyProduct("RatingExtension")]
|
||||
[assembly: AssemblyCopyright("Copyright (C) 2017-2020 Frank Skare (stax76)")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
135
src/Extensions/RatingExtension/RatingExtension.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
|
||||
// This extension writes a rating to the filename of rated videos when mpv.net shuts down.
|
||||
|
||||
// The input.conf setup:
|
||||
|
||||
// KP0 script-message rate-file 0 #menu: Extensions > Rating > 0stars
|
||||
// KP1 script-message rate-file 1 #menu: Extensions > Rating > 1stars
|
||||
// KP2 script-message rate-file 2 #menu: Extensions > Rating > 2stars
|
||||
// KP3 script-message rate-file 3 #menu: Extensions > Rating > 3stars
|
||||
// KP4 script-message rate-file 4 #menu: Extensions > Rating > 4stars
|
||||
// KP5 script-message rate-file 5 #menu: Extensions > Rating > 5stars
|
||||
// _ ignore #menu: Extensions > Rating > -
|
||||
// _ script-message rate-file about #menu: Extensions > Rating > About
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
|
||||
using mpvnet;
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace RatingExtension // the assembly name must end with 'Extension'!
|
||||
{
|
||||
[Export(typeof(IExtension))]
|
||||
public class RatingExtension : IExtension
|
||||
{
|
||||
//Script script = new Script();
|
||||
|
||||
// dictionory to store the filename and the rating
|
||||
Dictionary<string, int> Dic = new Dictionary<string, int>();
|
||||
|
||||
string FileToDelete;
|
||||
DateTime DeleteTime;
|
||||
|
||||
public RatingExtension() // plugin initialization
|
||||
{
|
||||
Core.ClientMessage += ClientMessage; //handles keys defined in input.conf
|
||||
Core.Shutdown += Shutdown; // handles MPV_EVENT_SHUTDOWN
|
||||
}
|
||||
|
||||
// handles MPV_EVENT_SHUTDOWN
|
||||
void Shutdown()
|
||||
{
|
||||
foreach (var i in Dic)
|
||||
{
|
||||
string filepath = i.Key;
|
||||
int rating = i.Value;
|
||||
|
||||
if (string.IsNullOrEmpty(filepath) || !File.Exists(filepath))
|
||||
return;
|
||||
|
||||
string basename = Path.GetFileNameWithoutExtension(filepath);
|
||||
|
||||
for (int x = 0; x < 6; x++)
|
||||
if (basename.Contains(" (" + x + "stars)"))
|
||||
basename = basename.Replace(" (" + x + "stars)", "");
|
||||
|
||||
basename += $" ({rating}stars)";
|
||||
|
||||
string newPath = Path.Combine(Path.GetDirectoryName(filepath),
|
||||
basename + Path.GetExtension(filepath));
|
||||
|
||||
if (filepath.ToLower() != newPath.ToLower())
|
||||
File.Move(filepath, newPath);
|
||||
|
||||
File.SetLastWriteTime(newPath, DateTime.Now);
|
||||
}
|
||||
}
|
||||
|
||||
//handles keys defined in input.conf
|
||||
void ClientMessage(string[] args)
|
||||
{
|
||||
if (args[0] != "rate-file")
|
||||
return;
|
||||
|
||||
if (int.TryParse(args[1], out int rating))
|
||||
{
|
||||
string path = Core.get_property_string("path");
|
||||
|
||||
if (!File.Exists(path))
|
||||
return;
|
||||
|
||||
if (rating == 0 || rating == 1)
|
||||
Delete(rating);
|
||||
else
|
||||
{
|
||||
Dic[path] = rating;
|
||||
Core.commandv("show-text", $"Rating: {rating}");
|
||||
}
|
||||
}
|
||||
else if (args[1] == "about")
|
||||
MessageBox.Show($"This extension writes a rating to the filename of rated videos " +
|
||||
"when mpv.net shuts down." + BR2 +
|
||||
"The input.conf defaults contain key bindings for this extension to set ratings.",
|
||||
"Rating Extension");
|
||||
}
|
||||
|
||||
void Delete(int rating)
|
||||
{
|
||||
if (rating == 0)
|
||||
{
|
||||
FileToDelete = Core.get_property_string("path");
|
||||
DeleteTime = DateTime.Now;
|
||||
Core.commandv("show-text", "Press 1 to delete file", "5000");
|
||||
}
|
||||
else
|
||||
{
|
||||
TimeSpan ts = DateTime.Now - DeleteTime;
|
||||
string path = Core.get_property_string("path");
|
||||
|
||||
if (FileToDelete == path && ts.TotalSeconds < 5 && File.Exists(FileToDelete))
|
||||
{
|
||||
Core.command("playlist-remove current");
|
||||
int pos = Core.get_property_int("playlist-pos");
|
||||
|
||||
if (pos == -1)
|
||||
{
|
||||
int count = Core.get_property_int("playlist-count");
|
||||
|
||||
if (count > 0)
|
||||
Core.set_property_int("playlist-pos", count - 1);
|
||||
}
|
||||
|
||||
Thread.Sleep(2000);
|
||||
FileSystem.DeleteFile(FileToDelete, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,72 +4,42 @@
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{06F854B0-00F9-4B53-94D9-0BE65A7C55D8}</ProjectGuid>
|
||||
<ProjectGuid>{55C88710-539D-4402-84C8-31694841C731}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TestAddon</RootNamespace>
|
||||
<AssemblyName>TestAddon</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<RootNamespace>RatingExtension</RootNamespace>
|
||||
<AssemblyName>RatingExtension</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
@@ -78,11 +48,12 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="TestAddon.cs" />
|
||||
<Compile Include="RatingExtension.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ScriptDevelopment.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\mpv.net\mpv.net.csproj">
|
||||
<ProjectReference Include="..\..\mpv.net.csproj">
|
||||
<Project>{1751f378-8edf-4b62-be6d-304c7c287089}</Project>
|
||||
<Name>mpv.net</Name>
|
||||
<Private>False</Private>
|
||||
42
src/Extensions/RatingExtension/ScriptDevelopment.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
//// This script adds dynamic menu items for profile switching.
|
||||
|
||||
//// In input.conf add a menu item called 'Profiles'
|
||||
|
||||
//using mpvnet;
|
||||
//using System.ComponentModel;
|
||||
//using System.Linq;
|
||||
|
||||
//class Script
|
||||
//{
|
||||
// MainForm MainForm;
|
||||
// CorePlayer Core;
|
||||
|
||||
// public Script()
|
||||
// {
|
||||
// Core = Global.Core;
|
||||
// MainForm = MainForm.Instance;
|
||||
// MainForm.ContextMenu.Opening += ContextMenu_Opening;
|
||||
// }
|
||||
|
||||
// void ContextMenu_Opening(object sender, CancelEventArgs e)
|
||||
// {
|
||||
// MenuItem menuItem = MainForm.FindMenuItem("My Menu");
|
||||
|
||||
// if (menuItem == null)
|
||||
// {
|
||||
// Terminal.WriteError("Profiles menu item not found.", "switch-profile-context-menu.cs");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// menuItem.DropDownItems.Clear();
|
||||
// var editionTracks = Core.MediaTracks.Where(track => track.Type == "e");
|
||||
|
||||
// foreach (int i in new[] {1, 2, 3})
|
||||
// {
|
||||
// MenuItem mi = new MenuItem(i.ToString());
|
||||
// mi.Action = () => { Core.commandv("show-text", i.ToString()); };
|
||||
// menuItem.DropDownItems.Add(mi);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
214
src/Misc/App.cs
Normal file
@@ -0,0 +1,214 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public static class App
|
||||
{
|
||||
public static string ConfPath { get => Core.ConfigFolder + "mpvnet.conf"; }
|
||||
public static string ProcessInstance { get; set; } = "single";
|
||||
public static string DarkMode { get; set; } = "always";
|
||||
public static string DarkTheme { get; set; } = "dark";
|
||||
public static string LightTheme { get; set; } = "light";
|
||||
public static string StartSize { get; set; } = "height-session";
|
||||
|
||||
public static bool RememberWindowPosition { get; set; }
|
||||
public static bool DebugMode { get; set; }
|
||||
public static bool IsStartedFromTerminal { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes";
|
||||
public static bool RememberVolume { get; set; } = true;
|
||||
public static bool AutoLoadFolder { get; set; } = true;
|
||||
public static bool Queue { get; set; }
|
||||
public static bool UpdateCheck { get; set; }
|
||||
|
||||
public static int StartThreshold { get; set; } = 1500;
|
||||
public static int RecentCount { get; set; } = 15;
|
||||
|
||||
public static float MinimumAspectRatio { get; set; } = 1.2f;
|
||||
|
||||
public static Extension Extension { get; set; }
|
||||
|
||||
public static bool IsDarkMode {
|
||||
get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
|
||||
}
|
||||
|
||||
static AppSettings _Settings;
|
||||
|
||||
public static AppSettings Settings {
|
||||
get {
|
||||
if (_Settings == null)
|
||||
_Settings = SettingsManager.Load();
|
||||
|
||||
return _Settings;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
var useless1 = Core.ConfigFolder;
|
||||
var useless2 = Core.Conf;
|
||||
|
||||
foreach (var i in Conf)
|
||||
ProcessProperty(i.Key, i.Value, true);
|
||||
|
||||
if (DebugMode)
|
||||
{
|
||||
try
|
||||
{
|
||||
string filePath = Core.ConfigFolder + "mpvnet-debug.log";
|
||||
|
||||
if (File.Exists(filePath))
|
||||
File.Delete(filePath);
|
||||
|
||||
Trace.Listeners.Add(new TextWriterTraceListener(filePath));
|
||||
Trace.AutoFlush = true;
|
||||
|
||||
//if (App.DebugMode)
|
||||
// Trace.WriteLine("");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Msg.ShowException(e);
|
||||
}
|
||||
}
|
||||
|
||||
InitTheme();
|
||||
|
||||
Core.Shutdown += Shutdown;
|
||||
Core.Initialized += Initialized;
|
||||
}
|
||||
|
||||
public static void InitTheme()
|
||||
{
|
||||
string themeContent = null;
|
||||
|
||||
if (File.Exists(Core.ConfigFolder + "theme.conf"))
|
||||
themeContent = File.ReadAllText(Core.ConfigFolder + "theme.conf");
|
||||
|
||||
Theme.Init(
|
||||
themeContent,
|
||||
Properties.Resources.theme,
|
||||
IsDarkMode ? DarkTheme : LightTheme);
|
||||
|
||||
ToolStripRendererEx.ForegroundColor = Theme.Current.GetWinFormsColor("menu-foreground");
|
||||
ToolStripRendererEx.BackgroundColor = Theme.Current.GetWinFormsColor("menu-background");
|
||||
ToolStripRendererEx.SelectionColor = Theme.Current.GetWinFormsColor("menu-highlight");
|
||||
ToolStripRendererEx.BorderColor = Theme.Current.GetWinFormsColor("menu-border");
|
||||
ToolStripRendererEx.CheckedColor = Theme.Current.GetWinFormsColor("menu-checked");
|
||||
}
|
||||
|
||||
public static void RunTask(Action action)
|
||||
{
|
||||
Task.Run(() => {
|
||||
try {
|
||||
action.Invoke();
|
||||
} catch (Exception e) {
|
||||
ShowException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static string Version {
|
||||
get {
|
||||
return "Copyright (C) 2000-2021 mpv.net/mpv/mplayer\n" +
|
||||
$"mpv.net {Application.ProductVersion} ({File.GetLastWriteTime(Application.ExecutablePath).ToShortDateString()})\n" +
|
||||
$"{Core.get_property_string("mpv-version")} ({File.GetLastWriteTime(Folder.Startup + "mpv-1.dll").ToShortDateString()})\nffmpeg {Core.get_property_string("ffmpeg-version")}\nMIT License";
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowException(object obj)
|
||||
{
|
||||
if (IsStartedFromTerminal)
|
||||
Terminal.WriteError(obj.ToString());
|
||||
else
|
||||
{
|
||||
if (obj is Exception e)
|
||||
Msg.ShowException(e);
|
||||
else
|
||||
Msg.ShowError(obj.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowError(string title, string msg = null)
|
||||
{
|
||||
if (IsStartedFromTerminal)
|
||||
{
|
||||
if (title != null)
|
||||
Terminal.WriteError(title);
|
||||
|
||||
if (msg != null)
|
||||
Terminal.WriteError(msg);
|
||||
}
|
||||
else
|
||||
Msg.ShowError(title, msg);
|
||||
}
|
||||
|
||||
static void Initialized()
|
||||
{
|
||||
if (RememberVolume)
|
||||
{
|
||||
Core.set_property_int("volume", Settings.Volume);
|
||||
Core.set_property_string("mute", Settings.Mute);
|
||||
}
|
||||
}
|
||||
|
||||
static void Shutdown()
|
||||
{
|
||||
Settings.Volume = Core.get_property_int("volume");
|
||||
Settings.Mute = Core.get_property_string("mute");
|
||||
|
||||
SettingsManager.Save(Settings);
|
||||
}
|
||||
|
||||
static Dictionary<string, string> _Conf;
|
||||
|
||||
public static Dictionary<string, string> Conf {
|
||||
get {
|
||||
if (_Conf == null)
|
||||
{
|
||||
_Conf = new Dictionary<string, string>();
|
||||
|
||||
if (File.Exists(ConfPath))
|
||||
foreach (string i in File.ReadAllLines(ConfPath))
|
||||
if (i.Contains("=") && !i.StartsWith("#"))
|
||||
_Conf[i.Substring(0, i.IndexOf("=")).Trim()] = i.Substring(i.IndexOf("=") + 1).Trim();
|
||||
}
|
||||
return _Conf;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ProcessProperty(string name, string value, bool writeError = false)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "remember-window-position": RememberWindowPosition = value == "yes"; return true;
|
||||
case "debug-mode": DebugMode = value == "yes"; return true;
|
||||
case "remember-volume": RememberVolume = value == "yes"; return true;
|
||||
case "queue": Queue = value == "yes"; return true;
|
||||
case "auto-load-folder": AutoLoadFolder = value == "yes"; return true;
|
||||
case "update-check": UpdateCheck = value == "yes"; return true;
|
||||
case "start-size": StartSize = value; return true;
|
||||
case "process-instance": ProcessInstance = value; return true;
|
||||
case "dark-mode": DarkMode = value; return true;
|
||||
case "start-threshold": StartThreshold = value.ToInt(); return true;
|
||||
case "recent-count": RecentCount = value.ToInt(); return true;
|
||||
case "minimum-aspect-ratio": MinimumAspectRatio = value.ToFloat(); return true;
|
||||
case "dark-theme": DarkTheme = value.Trim('\'', '"'); return true;
|
||||
case "light-theme": LightTheme = value.Trim('\'', '"'); return true;
|
||||
case "video-file-extensions": CorePlayer.VideoTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true;
|
||||
case "audio-file-extensions": CorePlayer.AudioTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true;
|
||||
case "image-file-extensions": CorePlayer.ImageTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true;
|
||||
default:
|
||||
if (writeError)
|
||||
Terminal.WriteError($"unknown mpvnet.conf property: {name}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
84
src/Misc/CSharpScriptHost.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
using Microsoft.CSharp;
|
||||
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
class CSharpScriptHost
|
||||
{
|
||||
static List<object> References = new List<object>();
|
||||
|
||||
public static void ExecuteScriptsInFolder(string folder)
|
||||
{
|
||||
if (Directory.Exists(folder))
|
||||
foreach (string file in Directory.GetFiles(folder, "*.cs"))
|
||||
App.RunTask(() => Execute(file));
|
||||
}
|
||||
|
||||
static void Execute(string file)
|
||||
{
|
||||
string code = File.ReadAllText(file);
|
||||
string filename = Path.GetFileNameWithoutExtension(file) + " " + GetMD5(code) + ".dll";
|
||||
string outputFile = Path.Combine(Path.GetTempPath(), filename);
|
||||
|
||||
if (!File.Exists(outputFile))
|
||||
Compile(outputFile, file);
|
||||
|
||||
if (File.Exists(outputFile))
|
||||
{
|
||||
object instance = Assembly.LoadFile(outputFile).CreateInstance("Script");
|
||||
|
||||
if (instance != null)
|
||||
References.Add(instance);
|
||||
else
|
||||
Terminal.WriteError("Failed to initialize script.", outputFile.FileName());
|
||||
}
|
||||
}
|
||||
|
||||
public static void Compile(string outputFile, string file)
|
||||
{
|
||||
CSharpCodeProvider provider = new CSharpCodeProvider();
|
||||
CompilerParameters parameters = new CompilerParameters();
|
||||
|
||||
string[] dependencies = {
|
||||
Folder.Startup + "mpvnet.exe",
|
||||
"Microsoft.VisualBasic.dll",
|
||||
"System.Core.dll", "System.Data.dll", "System.dll", "System.Drawing.dll", "System.Web.dll",
|
||||
"System.Windows.Forms.dll", "System.Xaml.dll", "System.Xml.dll", "System.Xml.Linq.dll",
|
||||
"WPF\\PresentationCore.dll", "WPF\\PresentationFramework.dll", "WPF\\WindowsBase.dll"
|
||||
};
|
||||
|
||||
foreach (string i in dependencies)
|
||||
parameters.ReferencedAssemblies.Add(i);
|
||||
|
||||
parameters.OutputAssembly = outputFile;
|
||||
CompilerResults results = provider.CompileAssemblyFromFile(parameters, file);
|
||||
|
||||
var errors = results.Errors.Cast<CompilerError>().Select(i => "Line Number " +
|
||||
i.Line + "\n" + "Error Number: " + i.ErrorNumber + "\n" + i.ErrorText);
|
||||
|
||||
if (errors.Count() > 0)
|
||||
Terminal.WriteError(string.Join(BR2, errors), Path.GetFileName(file));
|
||||
}
|
||||
|
||||
static string GetMD5(string code)
|
||||
{
|
||||
using (MD5 md5 = MD5.Create())
|
||||
{
|
||||
byte[] inputBuffer = Encoding.UTF8.GetBytes(code);
|
||||
byte[] hashBuffer = md5.ComputeHash(inputBuffer);
|
||||
return BitConverter.ToString(md5.ComputeHash(inputBuffer)).Replace("-", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
382
src/Misc/Commands.cs
Normal file
@@ -0,0 +1,382 @@
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows;
|
||||
|
||||
using VB = Microsoft.VisualBasic;
|
||||
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class Commands
|
||||
{
|
||||
public static void Execute(string id, string[] args = null)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case "add-files-to-playlist": OpenFiles("append"); break; // deprecated 2019
|
||||
case "cycle-audio": CycleAudio(); break;
|
||||
case "execute-mpv-command": Msg.ShowError("Command was removed, reset input.conf."); break;
|
||||
case "load-audio": LoadAudio(); break;
|
||||
case "load-sub": LoadSubtitle(); break;
|
||||
case "open-conf-folder": ProcessHelp.ShellExecute(Core.ConfigFolder); break;
|
||||
case "open-files": OpenFiles(args); break;
|
||||
case "open-optical-media": Open_DVD_Or_BD_Folder(); break;
|
||||
case "open-url": OpenURL(); break;
|
||||
case "playlist-first": PlaylistFirst(); break;
|
||||
case "playlist-last": PlaylistLast(); break;
|
||||
case "scale-window": ScaleWindow(float.Parse(args[0], CultureInfo.InvariantCulture)); break;
|
||||
case "shell-execute": ProcessHelp.ShellExecute(args[0]); break;
|
||||
case "show-about": ShowDialog(typeof(AboutWindow)); break;
|
||||
case "show-audio-devices": ShowTextWithEditor("audio-device-list", Core.get_property_osd_string("audio-device-list")); break;
|
||||
case "show-command-palette": ShowDialog(typeof(CommandPaletteWindow)); break;
|
||||
case "show-commands": ShowCommands(); break;
|
||||
case "show-conf-editor": ShowDialog(typeof(ConfWindow)); break;
|
||||
case "show-decoders": ShowTextWithEditor("decoder-list", mpvHelp.GetDecoders()); break;
|
||||
case "show-demuxers": ShowTextWithEditor("demuxer-lavf-list", mpvHelp.GetDemuxers()); break;
|
||||
case "show-history": ShowHistory(); break;
|
||||
case "show-info": ShowInfo(); break;
|
||||
case "show-input-editor": ShowDialog(typeof(InputWindow)); break;
|
||||
case "show-keys": ShowTextWithEditor("input-key-list", Core.get_property_string("input-key-list").Replace(",", BR)); break;
|
||||
case "show-media-search": ShowDialog(typeof(EverythingWindow)); break;
|
||||
case "show-playlist": ShowPlaylist(); break;
|
||||
case "show-profiles": ShowTextWithEditor("profile-list", mpvHelp.GetProfiles()); break;
|
||||
case "show-properties": ShowProperties(); break;
|
||||
case "show-protocols": ShowTextWithEditor("protocol-list", mpvHelp.GetProtocols()); break;
|
||||
case "show-setup-dialog": ShowDialog(typeof(SetupWindow)); break;
|
||||
case "show-text": ShowText(args[0], Convert.ToInt32(args[1]), Convert.ToInt32(args[2])); break;
|
||||
case "update-check": UpdateCheck.CheckOnline(true); break;
|
||||
case "window-scale": WindowScale(float.Parse(args[0], CultureInfo.InvariantCulture)); break;
|
||||
|
||||
default: Msg.ShowError($"No command '{id}' found."); break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void InvokeOnMainThread(Action action) => MainForm.Instance.BeginInvoke(action);
|
||||
|
||||
public static void ShowDialog(Type winType)
|
||||
{
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
Window win = Activator.CreateInstance(winType) as Window;
|
||||
new WindowInteropHelper(win).Owner = MainForm.Instance.Handle;
|
||||
win.ShowDialog();
|
||||
}));
|
||||
}
|
||||
|
||||
public static void OpenFiles(params string[] args)
|
||||
{
|
||||
bool append = Control.ModifierKeys.HasFlag(Keys.Control);
|
||||
bool loadFolder = true;
|
||||
|
||||
foreach (string arg in args)
|
||||
{
|
||||
if (arg == "append") append = true;
|
||||
if (arg == "no-folder") loadFolder = false;
|
||||
}
|
||||
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
using (var d = new OpenFileDialog() { Multiselect = true })
|
||||
if (d.ShowDialog() == DialogResult.OK)
|
||||
Core.LoadFiles(d.FileNames, loadFolder, append);
|
||||
}));
|
||||
}
|
||||
|
||||
public static void Open_DVD_Or_BD_Folder()
|
||||
{
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
using (var dialog = new FolderBrowserDialog())
|
||||
{
|
||||
dialog.Description = "Select a DVD or Blu-ray folder.";
|
||||
dialog.ShowNewFolderButton = false;
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Core.command("stop");
|
||||
Thread.Sleep(500);
|
||||
|
||||
if (Directory.Exists(dialog.SelectedPath + "\\BDMV"))
|
||||
{
|
||||
Core.set_property_string("bluray-device", dialog.SelectedPath);
|
||||
Core.LoadFiles(new[] { @"bd://" }, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Core.set_property_string("dvd-device", dialog.SelectedPath);
|
||||
Core.LoadFiles(new[] { @"dvd://" }, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public static void PlaylistFirst()
|
||||
{
|
||||
int pos = Core.get_property_int("playlist-pos");
|
||||
|
||||
if (pos != 0)
|
||||
Core.set_property_int("playlist-pos", 0);
|
||||
}
|
||||
|
||||
public static void PlaylistLast()
|
||||
{
|
||||
int pos = Core.get_property_int("playlist-pos");
|
||||
int count = Core.get_property_int("playlist-count");
|
||||
|
||||
if (pos < count - 1)
|
||||
Core.set_property_int("playlist-pos", count - 1);
|
||||
}
|
||||
|
||||
public static void ShowHistory()
|
||||
{
|
||||
if (File.Exists(Core.ConfigFolder + "history.txt"))
|
||||
ProcessHelp.ShellExecute(Core.ConfigFolder + "history.txt");
|
||||
else
|
||||
{
|
||||
if (Msg.ShowQuestion("Create history.txt file in config folder?",
|
||||
"mpv.net will write the date, time and filename of opened files to it.") == DialogResult.OK)
|
||||
|
||||
File.WriteAllText(Core.ConfigFolder + "history.txt", "");
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
string performer, title, album, genre, date, duration, text = "";
|
||||
long fileSize = 0;
|
||||
string path = Core.get_property_string("path");
|
||||
|
||||
if (path.Contains("://"))
|
||||
path = Core.get_property_string("media-title");
|
||||
|
||||
int width = Core.get_property_int("video-params/w");
|
||||
int height = Core.get_property_int("video-params/h");
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
fileSize = new FileInfo(path).Length;
|
||||
|
||||
if (CorePlayer.AudioTypes.Contains(path.Ext()))
|
||||
{
|
||||
using (MediaInfo mediaInfo = new MediaInfo(path))
|
||||
{
|
||||
performer = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Performer");
|
||||
title = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Title");
|
||||
album = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Album");
|
||||
genre = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Genre");
|
||||
date = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Recorded_Date");
|
||||
duration = mediaInfo.GetInfo(MediaInfoStreamKind.Audio, "Duration/String");
|
||||
|
||||
if (performer != "") text += "Artist: " + performer + "\n";
|
||||
if (title != "") text += "Title: " + title + "\n";
|
||||
if (album != "") text += "Album: " + album + "\n";
|
||||
if (genre != "") text += "Genre: " + genre + "\n";
|
||||
if (date != "") text += "Year: " + date + "\n";
|
||||
if (duration != "") text += "Length: " + duration + "\n";
|
||||
text += "Size: " + mediaInfo.GetInfo(MediaInfoStreamKind.General, "FileSize/String") + "\n";
|
||||
text += "Type: " + path.Ext().ToUpper();
|
||||
|
||||
Core.commandv("show-text", text, "5000");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (CorePlayer.ImageTypes.Contains(path.Ext()))
|
||||
{
|
||||
using (MediaInfo mediaInfo = new MediaInfo(path))
|
||||
{
|
||||
text =
|
||||
"Width: " + mediaInfo.GetInfo(MediaInfoStreamKind.Image, "Width") + "\n" +
|
||||
"Height: " + mediaInfo.GetInfo(MediaInfoStreamKind.Image, "Height") + "\n" +
|
||||
"Size: " + mediaInfo.GetInfo(MediaInfoStreamKind.General, "FileSize/String") + "\n" +
|
||||
"Type: " + path.Ext().ToUpper();
|
||||
|
||||
Core.commandv("show-text", text, "5000");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TimeSpan position = TimeSpan.FromSeconds(Core.get_property_number("time-pos"));
|
||||
TimeSpan duration2 = TimeSpan.FromSeconds(Core.get_property_number("duration"));
|
||||
string videoFormat = Core.get_property_string("video-format").ToUpper();
|
||||
string audioCodec = Core.get_property_string("audio-codec-name").ToUpper();
|
||||
|
||||
text = path.FileName() + "\n" +
|
||||
FormatTime(position.TotalMinutes) + ":" +
|
||||
FormatTime(position.Seconds) + " / " +
|
||||
FormatTime(duration2.TotalMinutes) + ":" +
|
||||
FormatTime(duration2.Seconds) + "\n" +
|
||||
$"{width} x {height}\n";
|
||||
|
||||
if (fileSize > 0)
|
||||
text += Convert.ToInt32(fileSize / 1024.0 / 1024.0) + " MB\n";
|
||||
|
||||
text += $"{videoFormat}\n{audioCodec}";
|
||||
|
||||
Core.commandv("show-text", text, "5000");
|
||||
string FormatTime(double value) => ((int)value).ToString("00");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
App.ShowException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void OpenURL()
|
||||
{
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
string clipboard = System.Windows.Forms.Clipboard.GetText();
|
||||
|
||||
if (string.IsNullOrEmpty(clipboard) || (!clipboard.Contains("://") && !File.Exists(clipboard)) ||
|
||||
clipboard.Contains("\n"))
|
||||
{
|
||||
App.ShowError("No URL found", "The clipboard does not contain a valid URL or file.");
|
||||
return;
|
||||
}
|
||||
|
||||
Core.LoadFiles(new [] { clipboard }, false, Control.ModifierKeys.HasFlag(Keys.Control));
|
||||
}));
|
||||
}
|
||||
|
||||
public static void LoadSubtitle()
|
||||
{
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
using (var d = new OpenFileDialog())
|
||||
{
|
||||
string path = Core.get_property_string("path");
|
||||
|
||||
if (File.Exists(path))
|
||||
d.InitialDirectory = Path.GetDirectoryName(path);
|
||||
|
||||
d.Multiselect = true;
|
||||
|
||||
if (d.ShowDialog() == DialogResult.OK)
|
||||
foreach (string filename in d.FileNames)
|
||||
Core.commandv("sub-add", filename);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public static void LoadAudio()
|
||||
{
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
using (var d = new OpenFileDialog())
|
||||
{
|
||||
string path = Core.get_property_string("path");
|
||||
if (File.Exists(path))
|
||||
d.InitialDirectory = Path.GetDirectoryName(path);
|
||||
d.Multiselect = true;
|
||||
|
||||
if (d.ShowDialog() == DialogResult.OK)
|
||||
foreach (string i in d.FileNames)
|
||||
Core.commandv("audio-add", i);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public static void CycleAudio()
|
||||
{
|
||||
MediaTrack[] audioTracks = Core.MediaTracks.Where(track => track.Type == "a").ToArray();
|
||||
int len = audioTracks.Length;
|
||||
|
||||
if (len < 1)
|
||||
{
|
||||
Core.commandv("show-text", "No audio tracks");
|
||||
return;
|
||||
}
|
||||
|
||||
int aid = Core.get_property_int("aid");
|
||||
|
||||
if (len > 1)
|
||||
{
|
||||
if (++aid > len)
|
||||
aid = 1;
|
||||
|
||||
Core.commandv("set", "aid", aid.ToString());
|
||||
}
|
||||
|
||||
Core.commandv("show-text", aid + "/" + len + ": " + audioTracks[aid - 1].Text.Substring(3), "5000");
|
||||
}
|
||||
|
||||
public static void ShowCommands()
|
||||
{
|
||||
string code = @"
|
||||
foreach ($item in ($json | ConvertFrom-Json | foreach { $_ } | sort name))
|
||||
{
|
||||
''
|
||||
$item.name
|
||||
|
||||
foreach ($arg in $item.args)
|
||||
{
|
||||
$value = $arg.name + ' <' + $arg.type.ToLower() + '>'
|
||||
|
||||
if ($arg.optional -eq $true)
|
||||
{
|
||||
$value = '[' + $value + ']'
|
||||
}
|
||||
|
||||
' ' + $value
|
||||
}
|
||||
}";
|
||||
|
||||
string json = Core.get_property_string("command-list");
|
||||
ShowTextWithEditor("command-list", PowerShell.InvokeAndReturnString(code, "json", json));
|
||||
}
|
||||
|
||||
public static void ShowProperties()
|
||||
{
|
||||
var props = Core.get_property_string("property-list").Split(',').OrderBy(prop => prop);
|
||||
ShowTextWithEditor("property-list", string.Join(BR, props));
|
||||
}
|
||||
|
||||
public static void ShowTextWithEditor(string name, string text)
|
||||
{
|
||||
string file = Path.GetTempPath() + $"\\{name}.txt";
|
||||
File.WriteAllText(file, BR + text.Trim() + BR);
|
||||
ProcessHelp.ShellExecute(file);
|
||||
}
|
||||
|
||||
public static void ScaleWindow(float factor) => Core.RaiseScaleWindow(factor);
|
||||
|
||||
public static void WindowScale(float value) => Core.RaiseWindowScale(value);
|
||||
|
||||
public static void ShowText(string text, int duration = 0, int fontSize = 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text))
|
||||
return;
|
||||
|
||||
if (duration == 0)
|
||||
duration = Core.get_property_int("osd-duration");
|
||||
|
||||
if (fontSize == 0)
|
||||
fontSize = Core.get_property_int("osd-font-size");
|
||||
|
||||
Core.command("show-text \"${osd-ass-cc/0}{\\\\fs" + fontSize +
|
||||
"}${osd-ass-cc/1}" + text + "\" " + duration);
|
||||
}
|
||||
|
||||
public static void ShowPlaylist(string[] args = null)
|
||||
{
|
||||
int duration = 5000;
|
||||
|
||||
if (args?.Length == 1)
|
||||
duration = Convert.ToInt32(args[0]);
|
||||
|
||||
var size = Core.get_property_number("osd-font-size");
|
||||
Core.set_property_number("osd-font-size", 40);
|
||||
Core.command("show-text ${playlist} " + duration);
|
||||
|
||||
App.RunTask(() => {
|
||||
Thread.Sleep(6000);
|
||||
Core.set_property_number("osd-font-size", size);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
1416
src/Misc/CorePlayer.cs
Normal file
65
src/Misc/Extension.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.ComponentModel.Composition.Hosting;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class Extension
|
||||
{
|
||||
[ImportMany]
|
||||
public IEnumerable<IExtension> Extensions = null;
|
||||
|
||||
readonly CompositionContainer CompositionContainer;
|
||||
|
||||
public Extension()
|
||||
{
|
||||
try
|
||||
{
|
||||
AggregateCatalog catalog = new AggregateCatalog();
|
||||
string dir = Folder.Startup + "Extensions";
|
||||
|
||||
if (Directory.Exists(dir))
|
||||
{
|
||||
string[] knownExtensions = { "RatingExtension", "ScriptingExtension" };
|
||||
|
||||
foreach (string extDir in Directory.GetDirectories(dir))
|
||||
{
|
||||
if (knownExtensions.Contains(Path.GetFileName(extDir)))
|
||||
catalog.Catalogs.Add(new DirectoryCatalog(extDir, Path.GetFileName(extDir) + ".dll"));
|
||||
else
|
||||
Terminal.WriteError("Failed to load extension:" + BR2 + extDir +
|
||||
BR2 + "Only extensions that ship with mpv.net are allowed in <startup>\\extensions" +
|
||||
BR2 + "User extensions have to use <config folder>\\extensions" +
|
||||
BR2 + "Never copy or install a new mpv.net version over a old mpv.net version.");
|
||||
}
|
||||
}
|
||||
|
||||
dir = Core.ConfigFolder + "extensions";
|
||||
|
||||
if (Directory.Exists(dir))
|
||||
foreach (string extDir in Directory.GetDirectories(dir))
|
||||
catalog.Catalogs.Add(new DirectoryCatalog(extDir, Path.GetFileName(extDir) + ".dll"));
|
||||
|
||||
if (catalog.Catalogs.Count > 0)
|
||||
{
|
||||
CompositionContainer = new CompositionContainer(catalog);
|
||||
CompositionContainer.ComposeParts(this);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
App.ShowException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IExtension
|
||||
{
|
||||
}
|
||||
}
|
||||
116
src/Misc/ExtensionMethods.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
public static class TestStringExtension
|
||||
{
|
||||
public static bool ContainsEx(this string instance, string value)
|
||||
{
|
||||
if (instance != null && value != null)
|
||||
return instance.Contains(value);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool StartsWithEx(this string instance, string value)
|
||||
{
|
||||
if (instance != null && value != null)
|
||||
return instance.StartsWith(value);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConvertToStringExtension
|
||||
{
|
||||
public static string ToUpperEx(this string instance)
|
||||
{
|
||||
if (instance != null)
|
||||
return instance.ToUpperInvariant();
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string ToLowerEx(this string instance)
|
||||
{
|
||||
if (instance != null)
|
||||
return instance.ToLowerInvariant();
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string TrimEx(this string instance)
|
||||
{
|
||||
if (instance == null)
|
||||
return "";
|
||||
|
||||
return instance.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConvertStringExtension
|
||||
{
|
||||
public static int ToInt(this string instance)
|
||||
{
|
||||
int.TryParse(instance, out int result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static float ToFloat(this string instance)
|
||||
{
|
||||
float.TryParse(instance.Replace(",", "."), NumberStyles.Float,
|
||||
CultureInfo.InvariantCulture, out float result);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PathStringExtension
|
||||
{
|
||||
// return extension with lower case and without dot.
|
||||
public static string Ext(this string instance)
|
||||
{
|
||||
if (instance == null)
|
||||
return "";
|
||||
|
||||
return Path.GetExtension(instance).TrimStart('.').ToLower();
|
||||
}
|
||||
|
||||
public static string FileName(this string instance)
|
||||
{
|
||||
if (string.IsNullOrEmpty(instance))
|
||||
return "";
|
||||
|
||||
int index = instance.LastIndexOf('\\');
|
||||
|
||||
if (index > -1)
|
||||
return instance.Substring(index + 1);
|
||||
|
||||
index = instance.LastIndexOf('/');
|
||||
|
||||
if (index > -1)
|
||||
return instance.Substring(index + 1);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
// Ensure trailing directory separator char
|
||||
public static string AddSep(this string instance)
|
||||
{
|
||||
if (string.IsNullOrEmpty(instance))
|
||||
return "";
|
||||
|
||||
if (!instance.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
||||
instance = instance + Path.DirectorySeparatorChar;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static bool IsIdenticalFolder(this string instance, string testFolder)
|
||||
{
|
||||
if (string.IsNullOrEmpty(instance) || string.IsNullOrEmpty(testFolder))
|
||||
return false;
|
||||
|
||||
return instance.ToLowerInvariant().AddSep() == testFolder.ToLowerInvariant().AddSep();
|
||||
}
|
||||
}
|
||||
13
src/Misc/Global.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class Global
|
||||
{
|
||||
public static string BR = Environment.NewLine;
|
||||
public static string BR2 = Environment.NewLine + Environment.NewLine;
|
||||
|
||||
public static CorePlayer Core { get; } = new CorePlayer();
|
||||
}
|
||||
}
|
||||
191
src/Misc/GlobalHotkey.cs
Normal file
@@ -0,0 +1,191 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
class GlobalHotkey
|
||||
{
|
||||
public static Dictionary<int, string> Commands { get; set; }
|
||||
static int ID;
|
||||
static IntPtr HWND;
|
||||
|
||||
public static void RegisterGlobalHotkeys(IntPtr hwnd)
|
||||
{
|
||||
HWND = hwnd;
|
||||
string path = Core.ConfigFolder + "global-input.conf";
|
||||
|
||||
if (!File.Exists(path))
|
||||
return;
|
||||
|
||||
foreach (string i in File.ReadAllLines(path))
|
||||
{
|
||||
string line = i.Trim();
|
||||
|
||||
if (line.StartsWith("#") || !line.Contains(" "))
|
||||
continue;
|
||||
|
||||
ProcessGlobalHotkeyLine(line);
|
||||
}
|
||||
}
|
||||
|
||||
static void ProcessGlobalHotkeyLine(string line)
|
||||
{
|
||||
string key = line.Substring(0, line.IndexOf(" "));
|
||||
string command = line.Substring(line.IndexOf(" ") + 1);
|
||||
string[] parts = key.Split('+');
|
||||
KeyModifiers mod = KeyModifiers.None;
|
||||
int vk;
|
||||
|
||||
for (int i = 0; i < parts.Length - 1; i++)
|
||||
{
|
||||
string umod = parts[i].ToUpper();
|
||||
|
||||
if (umod == "ALT") mod |= KeyModifiers.Alt;
|
||||
if (umod == "CTRL") mod |= KeyModifiers.Ctrl;
|
||||
if (umod == "SHIFT") mod |= KeyModifiers.Shift;
|
||||
if (umod == "WIN") mod |= KeyModifiers.Win;
|
||||
}
|
||||
|
||||
key = parts[parts.Length - 1];
|
||||
|
||||
if (key.Length == 1)
|
||||
{
|
||||
short result = VkKeyScanEx(key[0], GetKeyboardLayout(0));
|
||||
|
||||
int hi = result >> 8;
|
||||
int lo = result & 0xFF;
|
||||
|
||||
if (lo == -1)
|
||||
return;
|
||||
|
||||
vk = lo;
|
||||
|
||||
if ((hi & 1) == 1) mod |= KeyModifiers.Shift;
|
||||
if ((hi & 2) == 2) mod |= KeyModifiers.Ctrl;
|
||||
if ((hi & 4) == 4) mod |= KeyModifiers.Alt;
|
||||
}
|
||||
else
|
||||
vk = mpv_to_VK(key);
|
||||
|
||||
if (Commands == null)
|
||||
Commands = new Dictionary<int, string>();
|
||||
|
||||
if (vk > 0)
|
||||
{
|
||||
Commands[ID] = command.Trim();
|
||||
bool success = RegisterHotKey(HWND, ID++, mod, vk);
|
||||
|
||||
if (!success)
|
||||
Terminal.WriteError(line + ": " + new Win32Exception().Message + "\n", "global-input.conf");
|
||||
}
|
||||
}
|
||||
|
||||
public static void Execute(int id)
|
||||
{
|
||||
if (Commands.ContainsKey(id))
|
||||
Core.command(Commands[id]);
|
||||
}
|
||||
|
||||
static int mpv_to_VK(string value)
|
||||
{
|
||||
switch (value.ToUpperEx())
|
||||
{
|
||||
case "NEXT" : return 0xB0; // VK_MEDIA_NEXT_TRACK
|
||||
case "PREV" : return 0xB1; // VK_MEDIA_PREV_TRACK
|
||||
case "STOP" : return 0xB2; // VK_MEDIA_STOP
|
||||
case "PLAYPAUSE" : return 0xB3; // VK_MEDIA_PLAY_PAUSE
|
||||
case "SLEEP" : return 0x5F; // VK_SLEEP
|
||||
case "RIGHT" : return 0x27; // VK_RIGHT
|
||||
case "UP" : return 0x26; // VK_UP
|
||||
case "LEFT" : return 0x25; // VK_LEFT
|
||||
case "DOWN" : return 0x28; // VK_DOWN
|
||||
case "PGUP" : return 0x21; // VK_PRIOR
|
||||
case "PGDWN" : return 0x22; // VK_NEXT
|
||||
case "PAUSE" : return 0x13; // VK_PAUSE
|
||||
case "PRINT" : return 0x2A; // VK_PRINT
|
||||
case "HOME" : return 0x24; // VK_HOME
|
||||
case "INS" : return 0x2D; // VK_INSERT
|
||||
case "KP_INS" : return 0x2D; // VK_INSERT
|
||||
case "DEL" : return 0x2E; // VK_DELETE
|
||||
case "KP_DEL" : return 0x2E; // VK_DELETE
|
||||
case "END" : return 0x23; // VK_END
|
||||
case "F1" : return 0x70; // VK_F1
|
||||
case "F2" : return 0x71; // VK_F2
|
||||
case "F3" : return 0x72; // VK_F3
|
||||
case "F4" : return 0x73; // VK_F4
|
||||
case "F5" : return 0x74; // VK_F5
|
||||
case "F6" : return 0x75; // VK_F6
|
||||
case "F7" : return 0x76; // VK_F7
|
||||
case "F8" : return 0x77; // VK_F8
|
||||
case "F9" : return 0x78; // VK_F9
|
||||
case "F10" : return 0x79; // VK_F10
|
||||
case "F11" : return 0x7A; // VK_F11
|
||||
case "F12" : return 0x7B; // VK_F12
|
||||
case "F13" : return 0x7C; // VK_F13
|
||||
case "F14" : return 0x7D; // VK_F14
|
||||
case "F15" : return 0x7E; // VK_F15
|
||||
case "F16" : return 0x7F; // VK_F16
|
||||
case "F17" : return 0x80; // VK_F17
|
||||
case "F18" : return 0x81; // VK_F18
|
||||
case "F19" : return 0x82; // VK_F19
|
||||
case "F20" : return 0x83; // VK_F20
|
||||
case "F21" : return 0x84; // VK_F21
|
||||
case "F22" : return 0x85; // VK_F22
|
||||
case "F23" : return 0x86; // VK_F23
|
||||
case "F24" : return 0x87; // VK_F24
|
||||
case "ENTER" : return 0x0D; // VK_RETURN
|
||||
case "KP_ENTER" : return 0x0D; // VK_RETURN
|
||||
case "TAB" : return 0x09; // VK_TAB
|
||||
case "MENU" : return 0x5D; // VK_APPS
|
||||
case "CANCEL" : return 0x03; // VK_CANCEL
|
||||
case "BS" : return 0x08; // VK_BACK
|
||||
case "KP_DEC" : return 0x6E; // VK_DECIMAL
|
||||
case "ESC" : return 0x1B; // VK_ESCAPE
|
||||
case "KP0" : return 0x60; // VK_NUMPAD0
|
||||
case "KP1" : return 0x61; // VK_NUMPAD1
|
||||
case "KP2" : return 0x62; // VK_NUMPAD2
|
||||
case "KP3" : return 0x63; // VK_NUMPAD3
|
||||
case "KP4" : return 0x64; // VK_NUMPAD4
|
||||
case "KP5" : return 0x65; // VK_NUMPAD5
|
||||
case "KP6" : return 0x66; // VK_NUMPAD6
|
||||
case "KP7" : return 0x67; // VK_NUMPAD7
|
||||
case "KP8" : return 0x68; // VK_NUMPAD8
|
||||
case "KP9" : return 0x69; // VK_NUMPAD9
|
||||
case "FAVORITES" : return 0xAB; // VK_BROWSER_FAVORITES
|
||||
case "SEARCH" : return 0xAA; // VK_BROWSER_SEARCH
|
||||
case "MAIL" : return 0xB4; // VK_LAUNCH_MAIL
|
||||
case "VOLUME_UP" : return 0xAF; // VK_VOLUME_UP
|
||||
case "VOLUME_DOWN": return 0xAE; // VK_VOLUME_DOWN
|
||||
case "MUTE" : return 0xAD; // VK_VOLUME_MUTE
|
||||
case "SPACE" : return 0x20; // VK_SPACE
|
||||
case "IDEOGRAPHIC_SPACE": return 0x20; // VK_SPACE
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
static extern short VkKeyScanEx(char ch, IntPtr dwhkl);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern IntPtr GetKeyboardLayout(uint idThread);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
static extern bool RegisterHotKey(IntPtr hWnd, int id, KeyModifiers fsModifiers, int vk);
|
||||
|
||||
[Flags]
|
||||
enum KeyModifiers
|
||||
{
|
||||
None = 0,
|
||||
Alt = 1,
|
||||
Ctrl = 2,
|
||||
Shift = 4,
|
||||
Win = 8
|
||||
}
|
||||
}
|
||||
}
|
||||
189
src/Misc/Help.cs
Normal file
@@ -0,0 +1,189 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Microsoft.Win32;
|
||||
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public static class ProcessHelp
|
||||
{
|
||||
public static void Execute(string file, string arguments = null)
|
||||
{
|
||||
using (Process proc = new Process())
|
||||
{
|
||||
proc.StartInfo.FileName = file;
|
||||
proc.StartInfo.Arguments = arguments;
|
||||
proc.StartInfo.UseShellExecute = false;
|
||||
proc.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShellExecute(string file, string arguments = null)
|
||||
{
|
||||
using (Process proc = new Process())
|
||||
{
|
||||
proc.StartInfo.FileName = file;
|
||||
proc.StartInfo.Arguments = arguments;
|
||||
proc.StartInfo.UseShellExecute = true;
|
||||
proc.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CursorHelp
|
||||
{
|
||||
static bool IsVisible = true;
|
||||
|
||||
public static void Show()
|
||||
{
|
||||
if (!IsVisible)
|
||||
{
|
||||
Cursor.Show();
|
||||
IsVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Hide()
|
||||
{
|
||||
if (IsVisible)
|
||||
{
|
||||
Cursor.Hide();
|
||||
IsVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsPosDifferent(Point screenPos)
|
||||
{
|
||||
return
|
||||
Math.Abs(screenPos.X - Control.MousePosition.X) > 10 ||
|
||||
Math.Abs(screenPos.Y - Control.MousePosition.Y) > 10;
|
||||
}
|
||||
}
|
||||
|
||||
public class mpvHelp
|
||||
{
|
||||
public static string GetProfiles()
|
||||
{
|
||||
string code = @"
|
||||
foreach ($item in ($json | ConvertFrom-Json | foreach { $_ } | sort name))
|
||||
{
|
||||
$item.name
|
||||
''
|
||||
|
||||
foreach ($option in $item.options)
|
||||
{
|
||||
' ' + $option.key + ' = ' + $option.value
|
||||
}
|
||||
|
||||
''
|
||||
}";
|
||||
|
||||
string json = Core.get_property_string("profile-list");
|
||||
return PowerShell.InvokeAndReturnString(code, "json", json).Trim();
|
||||
}
|
||||
|
||||
public static string GetDecoders()
|
||||
{
|
||||
string code = @"
|
||||
foreach ($item in ($json | ConvertFrom-Json | foreach { $_ } | sort codec))
|
||||
{
|
||||
$item.codec + ' - ' + $item.description
|
||||
}";
|
||||
|
||||
string json = Core.get_property_string("decoder-list");
|
||||
return PowerShell.InvokeAndReturnString(code, "json", json).Trim();
|
||||
}
|
||||
|
||||
public static string GetProtocols()
|
||||
{
|
||||
string list = Core.get_property_string("protocol-list");
|
||||
return string.Join(BR, list.Split(',').OrderBy(a => a));
|
||||
}
|
||||
|
||||
public static string GetDemuxers()
|
||||
{
|
||||
string list = Core.get_property_string("demuxer-lavf-list");
|
||||
return string.Join(BR, list.Split(',').OrderBy(a => a));
|
||||
}
|
||||
}
|
||||
|
||||
public class RegistryHelp
|
||||
{
|
||||
public static string ApplicationKey { get; } = @"HKCU\Software\" + Application.ProductName;
|
||||
|
||||
public static void SetInt(string name, object value)
|
||||
{
|
||||
SetValue(ApplicationKey, name, value);
|
||||
}
|
||||
|
||||
public static void SetString(string name, string value)
|
||||
{
|
||||
SetValue(ApplicationKey, name, value);
|
||||
}
|
||||
|
||||
public static void SetValue(string name, object value)
|
||||
{
|
||||
using (RegistryKey regKey = GetRootKey(ApplicationKey).CreateSubKey(ApplicationKey.Substring(5), RegistryKeyPermissionCheck.ReadWriteSubTree))
|
||||
regKey.SetValue(name, value);
|
||||
}
|
||||
|
||||
public static void SetValue(string path, string name, object value)
|
||||
{
|
||||
using (RegistryKey regKey = GetRootKey(path).CreateSubKey(path.Substring(5), RegistryKeyPermissionCheck.ReadWriteSubTree))
|
||||
regKey.SetValue(name, value);
|
||||
}
|
||||
|
||||
public static string GetString(string name, string defaultValue = "")
|
||||
{
|
||||
object value = GetValue(ApplicationKey, name, defaultValue);
|
||||
return !(value is string) ? defaultValue : value.ToString();
|
||||
}
|
||||
|
||||
public static int GetInt(string name, int defaultValue = 0)
|
||||
{
|
||||
object value = GetValue(ApplicationKey, name, defaultValue);
|
||||
return !(value is int) ? defaultValue : (int)value;
|
||||
}
|
||||
|
||||
public static object GetValue(string name) => GetValue(ApplicationKey, name, null);
|
||||
|
||||
public static object GetValue(string path, string name, object defaultValue = null)
|
||||
{
|
||||
using (RegistryKey regKey = GetRootKey(path).OpenSubKey(path.Substring(5)))
|
||||
return regKey == null ? null : regKey.GetValue(name, defaultValue);
|
||||
}
|
||||
|
||||
public static void RemoveKey(string path)
|
||||
{
|
||||
try {
|
||||
GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false);
|
||||
} catch { }
|
||||
}
|
||||
|
||||
public static void RemoveValue(string path, string name)
|
||||
{
|
||||
try {
|
||||
using (RegistryKey regKey = GetRootKey(path).OpenSubKey(path.Substring(5), true))
|
||||
if (regKey != null)
|
||||
regKey.DeleteValue(name, false);
|
||||
} catch { }
|
||||
}
|
||||
|
||||
static RegistryKey GetRootKey(string path)
|
||||
{
|
||||
switch (path.Substring(0, 4))
|
||||
{
|
||||
case "HKLM": return Registry.LocalMachine;
|
||||
case "HKCU": return Registry.CurrentUser;
|
||||
case "HKCR": return Registry.ClassesRoot;
|
||||
default: throw new Exception();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||