Fix crash on Windows 7 systems without PowerShell.

This commit is contained in:
stax76
2022-03-24 18:32:32 +01:00
parent 1aa380f768
commit 3f469897b0
4 changed files with 52 additions and 26 deletions

View File

@@ -1,4 +1,5 @@
- Fix crash on Windows 7 systems without PowerShell.
- Fix showing incorrect timestamps in About dialog of Store version. - Fix showing incorrect timestamps in About dialog of Store version.
- Fix Store page showing non existant ARM and x86 support. - Fix Store page showing non existant ARM and x86 support.
- Fix opening zip files. - Fix opening zip files.
@@ -7,8 +8,9 @@
- Media Info isn't shown directly, instead the command palette - Media Info isn't shown directly, instead the command palette
shows several choices. The command palette can be bypassed shows several choices. The command palette can be bypassed
using the arguments: msgbox, editor, full, raw. using the arguments: msgbox, editor, full, raw.
- mpv.net specific commands are documented in the manual. - mpv.net specific commands, the command palette, auto-play property
- The command palette and auto-play property is documented in the manual. and various other things are documented in the manual.
5.7.0.0 Stable (2022-03-09) 5.7.0.0 Stable (2022-03-09)

View File

@@ -232,6 +232,7 @@ namespace mpvnet
if (!Directory.Exists(_ConfigFolder)) if (!Directory.Exists(_ConfigFolder))
{ {
try {
using (Process proc = new Process()) using (Process proc = new Process())
{ {
proc.StartInfo.UseShellExecute = false; proc.StartInfo.UseShellExecute = false;
@@ -241,6 +242,7 @@ namespace mpvnet
proc.Start(); proc.Start();
proc.WaitForExit(); proc.WaitForExit();
} }
} catch (Exception) {}
if (!Directory.Exists(_ConfigFolder)) if (!Directory.Exists(_ConfigFolder))
Directory.CreateDirectory(_ConfigFolder); Directory.CreateDirectory(_ConfigFolder);

14
src/Scripts/Lua/.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,14 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "lua",
"request": "launch",
"name": "launch",
"runtimeExecutable": "D:/Software/Development/MSYS2/mingw64/bin/mpv.exe",
"runtimeArgs": ["--script=${workspaceFolder}\\delete-current-file.lua", "D:\\Samples\\castele.m2v"],
"stopOnEntry": false,
"luaVersion": "5.1"
}
]
}

View File

@@ -1,5 +1,13 @@
-- This script deletes the file that is currently playing. -- Only supported on Windows.
-- This script deletes the file that is currently playing
-- via keyboard shortcut, the file is moved to the recycle bin.
-- Usage:
-- Configure input.conf as described below.
-- Press 0 to initiate the delete operation.
-- Press 1 to confirm and delete.
-- input.conf: -- input.conf:
@@ -10,30 +18,30 @@
-- 1 script-binding delete_current_file/confirm -- 1 script-binding delete_current_file/confirm
function delete() function delete()
FileToDelete = mp.get_property("path") file_to_delete = mp.get_property("path")
DeleteTime = os.time() delete_time = os.time()
mp.commandv("show-text", "Press 1 to delete file", "10000") mp.commandv("show-text", "Press 1 to delete file", "10000")
end end
function confirm() function confirm()
local path = mp.get_property("path") local path = mp.get_property("path")
if FileToDelete == path and (os.time() - DeleteTime) < 10 then if file_to_delete == path and (os.time() - delete_time) < 10 then
mp.commandv("show-text", "") mp.commandv("show-text", "")
local count = mp.get_property_number("playlist-count") local count = mp.get_property_number("playlist-count")
local pos = mp.get_property_number("playlist-pos") local pos = mp.get_property_number("playlist-pos")
local newPos = 0 local new_pos = 0
if pos == count - 1 then if pos == count - 1 then
newPos = pos - 1 new_pos = pos - 1
else else
newPos = pos + 1 new_pos = pos + 1
end end
if newPos > -1 then if new_pos > -1 then
mp.command("set pause no") mp.command("set pause no")
mp.set_property_number("playlist-pos", newPos) mp.set_property_number("playlist-pos", new_pos)
end end
mp.command("playlist-remove " .. pos) mp.command("playlist-remove " .. pos)
@@ -41,13 +49,13 @@ function confirm()
local ps_code = [[& { local ps_code = [[& {
Start-Sleep -Seconds 2 Start-Sleep -Seconds 2
Add-Type -AssemblyName Microsoft.VisualBasic Add-Type -AssemblyName Microsoft.VisualBasic
[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile('FileToDelete', 'OnlyErrorDialogs', 'SendToRecycleBin') [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile('file_to_delete', 'OnlyErrorDialogs', 'SendToRecycleBin')
}]] }]]
local escapedFileToDelete = string.gsub(FileToDelete, "'", "''") local escaped_file_to_delete = string.gsub(file_to_delete, "'", "''")
escapedFileToDelete = string.gsub(escapedFileToDelete, "", "") escaped_file_to_delete = string.gsub(escaped_file_to_delete, "", "")
escapedFileToDelete = string.gsub(escapedFileToDelete, "%%", "%%%%") escaped_file_to_delete = string.gsub(escaped_file_to_delete, "%%", "%%%%")
ps_code = string.gsub(ps_code, "FileToDelete", escapedFileToDelete) ps_code = string.gsub(ps_code, "file_to_delete", escaped_file_to_delete)
mp.command_native({ mp.command_native({
name = "subprocess", name = "subprocess",