Last active
January 29, 2020 14:07
-
-
Save gabrielfern/566f4676417d7aa2eb3136de0cfdabf3 to your computer and use it in GitHub Desktop.
mpv - Move position of entry in playlist and remove entries from playlist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function notify_new_pos(pos, count) | |
mp.osd_message('New position in playlist ['.. pos ..'/'..count..']') | |
mp.msg.info('New position in playlist ['.. pos ..'/'..count..']') | |
end | |
function move_up() | |
local pos = mp.get_property_number('playlist-pos') | |
local count = mp.get_property_number('playlist-count') | |
if pos >= 1 then | |
mp.commandv('playlist-move', pos, pos - 1) | |
notify_new_pos(pos, count) | |
else | |
--mp.commandv('playlist-move', pos, count) In case you wanna cycle playlist | |
--notify_new_pos(count, count) | |
end | |
end | |
function move_down() | |
local pos = mp.get_property_number('playlist-pos') | |
local count = mp.get_property_number('playlist-count') | |
if pos + 2 <= count then | |
mp.commandv('playlist-move', pos, pos + 2) | |
notify_new_pos(pos + 2, count) | |
else | |
--mp.commandv('playlist-move', pos, 0) In case you wanna cycle playlist | |
--notify_new_pos(1, count) | |
end | |
end | |
function remove_current() | |
local pos = mp.get_property_number('playlist-pos') | |
local count = mp.get_property_number('playlist-count') | |
local title = mp.get_property('media-title') | |
if pos == count - 1 and count > 1 then | |
mp.set_property('playlist-pos', pos - 1) | |
mp.commandv('playlist-remove', pos) | |
else | |
mp.commandv('playlist-remove', 'current') | |
end | |
mp.osd_message('Removed '..title..' from playlist') | |
mp.msg.info('Removed '..title..' from playlist') | |
end | |
mp.add_key_binding('f1', 'move_up', move_up) | |
mp.add_key_binding('f2', 'move_down', move_down) | |
mp.add_key_binding('ctrl+d', 'remove_current', remove_current) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment