context menu issue fix #396

This commit is contained in:
stax76
2022-03-31 16:22:54 +02:00
parent 3f469897b0
commit 9a33bea7e7
10 changed files with 66 additions and 208 deletions

View File

@@ -1,35 +0,0 @@
// When seeking displays position and duration like so: 70:00 / 80:00
// Which is different from most players which use: 01:10:00 / 01:20:00
// In input.conf set the input command prefix no-osd infront of the seek command.
function add_zero(val)
{
val = Math.round(val);
return val > 9 ? "" + val : "0" + val;
}
function format(val)
{
var sec = Math.round(val);
if (sec < 0)
sec = 0;
pos_min_floor = Math.floor(sec / 60);
sec_rest = sec - pos_min_floor * 60;
return add_zero(pos_min_floor) + ":" + add_zero(sec_rest);
}
function on_seek(_)
{
pos = mp.get_property_number("time-pos");
dur = mp.get_property_number("duration");
if (pos > dur)
pos = dur;
mp.commandv("show-text", format(pos) + " / " + format(dur));
}
mp.register_event("seek", on_seek);

View File

@@ -1,26 +0,0 @@
// This script shows the playlist.
function showPlaylist()
{
// set font size
mp.set_property_number("osd-font-size", 40);
// show playlist for 5 seconds
mp.command("show-text ${playlist} 5000");
// restore original font size in 6 seconds
setTimeout(resetFontSize, 6000);
}
// restore original font size
function resetFontSize()
{
mp.set_property_number("osd-font-size", size);
}
// save original font size
var size = mp.get_property_number("osd-font-size");
// input.conf: key script-binding show-playlist
mp.add_key_binding(null, "show-playlist", showPlaylist);

View File

@@ -1,14 +0,0 @@
{
"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,70 +0,0 @@
-- 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:
-- KP0 script-binding delete_current_file/delete
-- 0 script-binding delete_current_file/delete
-- KP1 script-binding delete_current_file/confirm
-- 1 script-binding delete_current_file/confirm
function delete()
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 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 new_pos = 0
if pos == count - 1 then
new_pos = pos - 1
else
new_pos = pos + 1
end
if new_pos > -1 then
mp.command("set pause no")
mp.set_property_number("playlist-pos", new_pos)
end
mp.command("playlist-remove " .. pos)
local ps_code = [[& {
Start-Sleep -Seconds 2
Add-Type -AssemblyName Microsoft.VisualBasic
[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile('file_to_delete', 'OnlyErrorDialogs', 'SendToRecycleBin')
}]]
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",
playback_only = false,
detach = true,
args = { 'powershell', '-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', ps_code },
})
end
end
mp.add_key_binding(nil, "delete", delete)
mp.add_key_binding(nil, "confirm", confirm)

View File

@@ -1,23 +0,0 @@
-- https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/pause-when-minimize.lua
-- This script pauses playback when minimizing the window, and resumes playback
-- if it's brought back again. If the player was already paused when minimizing,
-- then try not to mess with the pause state.
local did_minimize = false
mp.observe_property("window-minimized", "bool", function(name, value)
local pause = mp.get_property_native("pause")
if value == true then
if pause == false then
mp.set_property_native("pause", true)
did_minimize = true
end
elseif value == false then
if did_minimize and (pause == true) then
mp.set_property_native("pause", false)
end
did_minimize = false
end
end)