-
Notifications
You must be signed in to change notification settings - Fork 6
/
custom-osc.lua
72 lines (63 loc) · 2.04 KB
/
custom-osc.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
local dragging = false
local prevX = 0
function leftClick()
mouseEvent("leftClick")
end
function leftDoubleClick()
mouseEvent("leftDoubleClick")
end
function dragSeek(kevent)
if(kevent["event"] == "down") then
local x, y = mp.get_mouse_pos()
prevX = x
dragging = true
else
dragging = false
end
end
function mouseEvent(event)
local x, y = mp.get_mouse_pos()
local window_width = mp.get_property("osd-width")
local window_height = mp.get_property("osd-height")
local bottomArea = window_height * .8
local leftArea = window_width * .2
local rightArea = window_width * .8
local seek_perc = (x / window_width) * 100
if(y > bottomArea) then
mp.commandv('osd-msg-bar','seek',seek_perc, 'absolute-percent')
elseif(x < leftArea and y < bottomArea) then
mp.commandv('playlist-prev')
elseif(x > rightArea and y < bottomArea) then
mp.commandv('playlist-next')
else
if(event == "leftClick") then
mp.commandv('cycle','pause')
elseif(event == "leftDoubleClick") then
mp.commandv('cycle','fullscreen')
end
end
end
function mouseMove()
local x, y = mp.get_mouse_pos()
local width = mp.get_property("osd-width")
local height = mp.get_property("osd-height")
local seekArea = height * .8
if(y > seekArea) then
mp.commandv('osd-msg-bar','show-progress')
end
if(dragging == true) then
local x, y = mp.get_mouse_pos()
local diff = (prevX - x);
if(diff > 2) then
mp.commandv('osd-msg-bar','seek',.5)
prevX = x
elseif (diff < -2) then
mp.commandv('osd-msg-bar','seek',-.5)
prevX = x
end
end
end
mp.add_forced_key_binding("MBTN_RIGHT", "dragSeek", dragSeek, { repeatable = false; complex = true })
mp.register_script_message("custom-osc-left-click", leftClick)
mp.register_script_message("custom-osc-left-double-click", leftDoubleClick)
mp.register_script_message("custom-osc-mouse-move", mouseMove)