add mouse control

- also use forced key binding
This commit is contained in:
wood 2019-10-12 11:10:06 +03:00
parent 37ddeec5a5
commit 63ecedc95e
2 changed files with 23 additions and 16 deletions

View File

@ -5,17 +5,17 @@ Script for watching iptv with mpv.
INSTALL INSTALL
Put in ~/.config/mpv/scripts/ Put in ~/.config/mpv/scripts/
RUN RUN
mpv --script-opts=iptv=1 playlist.m3u mpv --script-opts=iptv=1 playlist.m3u
CONTROL CONTROL
\ — to show/hide playlist \ or Mouse right click — to show/hide playlist
UP/DOWN — to navigate UP/DOWN or Mouse scroll — to navigate
type with keyboard — to search incrementally type with keyboard — to search incrementally
ENTER — to play ENTER or Mouse left click — to play

View File

@ -163,28 +163,34 @@ for _,v in ipairs({',','^','$','(',')','%','.','[',']','*','+','-','?','`',"'","
end end
function add_bindings() function add_bindings()
mp.add_key_binding('UP', 'plsup', up,"repeatable") mp.add_forced_key_binding('UP', 'plsup1', up,"repeatable")
mp.add_key_binding('DOWN', 'plsdown', down,"repeatable") mp.add_forced_key_binding('MOUSE_BTN3', 'plsup2', up,"repeatable")
mp.add_forced_key_binding('DOWN', 'plsdown1', down,"repeatable")
mp.add_forced_key_binding('MOUSE_BTN4', 'plsdown2', down,"repeatable")
for i,v in ipairs(chars) do for i,v in ipairs(chars) do
c=string.char(v) c=string.char(v)
mp.add_key_binding(c, 'search'..v, typing(c),"repeatable") mp.add_forced_key_binding(c, 'search'..v, typing(c),"repeatable")
end end
mp.add_key_binding('SPACE', 'search32', typing(' '),"repeatable") mp.add_forced_key_binding('SPACE', 'search32', typing(' '),"repeatable")
--[[ mp.add_key_binding('а', 'search1000', typing('а'),"repeatable") --[[ mp.add_key_binding('а', 'search1000', typing('а'),"repeatable")
mp.add_key_binding('с', 'search1001', typing('с'),"repeatable")]] mp.add_key_binding('с', 'search1001', typing('с'),"repeatable")]]
mp.add_key_binding('BS', 'searchbs', backspace,"repeatable") mp.add_forced_key_binding('BS', 'searchbs', backspace,"repeatable")
mp.add_key_binding('ENTER', 'plsenter', play) mp.add_forced_key_binding('ENTER', 'plsenter1', play)
mp.add_forced_key_binding('MOUSE_BTN0', 'plsenter2', play)
for i,v in ipairs(cyr_chars) do for i,v in ipairs(cyr_chars) do
mp.add_key_binding(v, 'search'..i+1000, typing(v),"repeatable") mp.add_forced_key_binding(v, 'search'..i+1000, typing(v),"repeatable")
end end
end end
function remove_bindings() function remove_bindings()
mp.remove_key_binding('plsup') mp.remove_key_binding('plsup1')
mp.remove_key_binding('plsdown') mp.remove_key_binding('plsup2')
mp.remove_key_binding('plsenter') mp.remove_key_binding('plsdown1')
mp.remove_key_binding('plsdown2')
mp.remove_key_binding('plsenter1')
mp.remove_key_binding('plsenter2')
for i,v in ipairs(chars) do for i,v in ipairs(chars) do
c=string.char(v) c=string.char(v)
mp.remove_key_binding('search'..v) mp.remove_key_binding('search'..v)
@ -409,7 +415,8 @@ if mp.get_opt("iptv") then
mp.set_property_bool("idle", true) mp.set_property_bool("idle", true)
mp.set_property_bool("force-window", true) mp.set_property_bool("force-window", true)
mp.register_event("start-file", on_start_file) mp.register_event("start-file", on_start_file)
mp.add_key_binding('\\', 'activate', activate) mp.add_forced_key_binding('\\', 'activate1', activate)
mp.add_forced_key_binding('MOUSE_BTN2', 'activate2', activate)
mp.set_property("fullscreen", "yes") mp.set_property("fullscreen", "yes")
end end