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 Store page showing non existant ARM and x86 support.
- Fix opening zip files.
@@ -7,8 +8,9 @@
- Media Info isn't shown directly, instead the command palette
shows several choices. The command palette can be bypassed
using the arguments: msgbox, editor, full, raw.
- mpv.net specific commands are documented in the manual.
- The command palette and auto-play property is documented in the manual.
- mpv.net specific commands, the command palette, auto-play property
and various other things are documented in the manual.
5.7.0.0 Stable (2022-03-09)

View File

@@ -232,15 +232,17 @@ namespace mpvnet
if (!Directory.Exists(_ConfigFolder))
{
using (Process proc = new Process())
{
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.FileName = "powershell.exe";
proc.StartInfo.Arguments = $@"-Command New-Item -Path '{_ConfigFolder}' -ItemType Directory";
proc.Start();
proc.WaitForExit();
}
try {
using (Process proc = new Process())
{
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.FileName = "powershell.exe";
proc.StartInfo.Arguments = $@"-Command New-Item -Path '{_ConfigFolder}' -ItemType Directory";
proc.Start();
proc.WaitForExit();
}
} catch (Exception) {}
if (!Directory.Exists(_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:
@@ -10,30 +18,30 @@
-- 1 script-binding delete_current_file/confirm
function delete()
FileToDelete = mp.get_property("path")
DeleteTime = os.time()
file_to_delete = mp.get_property("path")
delete_time = os.time()
mp.commandv("show-text", "Press 1 to delete file", "10000")
end
function confirm()
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", "")
local count = mp.get_property_number("playlist-count")
local pos = mp.get_property_number("playlist-pos")
local newPos = 0
local pos = mp.get_property_number("playlist-pos")
local new_pos = 0
if pos == count - 1 then
newPos = pos - 1
new_pos = pos - 1
else
newPos = pos + 1
new_pos = pos + 1
end
if newPos > -1 then
if new_pos > -1 then
mp.command("set pause no")
mp.set_property_number("playlist-pos", newPos)
mp.set_property_number("playlist-pos", new_pos)
end
mp.command("playlist-remove " .. pos)
@@ -41,13 +49,13 @@ function confirm()
local ps_code = [[& {
Start-Sleep -Seconds 2
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, "'", "''")
escapedFileToDelete = string.gsub(escapedFileToDelete, "", "")
escapedFileToDelete = string.gsub(escapedFileToDelete, "%%", "%%%%")
ps_code = string.gsub(ps_code, "FileToDelete", escapedFileToDelete)
local escaped_file_to_delete = string.gsub(file_to_delete, "'", "''")
escaped_file_to_delete = string.gsub(escaped_file_to_delete, "", "")
escaped_file_to_delete = string.gsub(escaped_file_to_delete, "%%", "%%%%")
ps_code = string.gsub(ps_code, "file_to_delete", escaped_file_to_delete)
mp.command_native({
name = "subprocess",