Skip to content

Instantly share code, notes, and snippets.

@gabrielfern
Last active January 29, 2020 14:07
Show Gist options
  • Select an option

  • Save gabrielfern/566f4676417d7aa2eb3136de0cfdabf3 to your computer and use it in GitHub Desktop.

Select an option

Save gabrielfern/566f4676417d7aa2eb3136de0cfdabf3 to your computer and use it in GitHub Desktop.

Revisions

  1. gabrielfern revised this gist Jan 29, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions playlist_operations.lua
    Original file line number Diff line number Diff line change
    @@ -32,7 +32,7 @@ end
    function remove_current()
    local pos = mp.get_property_number('playlist-pos')
    local count = mp.get_property_number('playlist-count')
    local filename = mp.get_property('playlist/'..pos..'/filename')
    local title = mp.get_property('media-title')

    if pos == count - 1 and count > 1 then
    mp.set_property('playlist-pos', pos - 1)
    @@ -41,8 +41,8 @@ function remove_current()
    mp.commandv('playlist-remove', 'current')
    end

    mp.osd_message('Removed '..filename..' from playlist')
    mp.msg.info('Removed '..filename..' from playlist')
    mp.osd_message('Removed '..title..' from playlist')
    mp.msg.info('Removed '..title..' from playlist')
    end

    mp.add_key_binding('f1', 'move_up', move_up)
  2. gabrielfern renamed this gist Jan 29, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions move_remove_from_playlist.lua → playlist_operations.lua
    Original file line number Diff line number Diff line change
    @@ -45,6 +45,6 @@ function remove_current()
    mp.msg.info('Removed '..filename..' from playlist')
    end

    mp.add_key_binding('\\', 'move_up', move_up)
    mp.add_key_binding('x', 'move_down', move_down)
    mp.add_key_binding('z', 'remove_current', remove_current)
    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)
  3. gabrielfern created this gist Jan 28, 2020.
    50 changes: 50 additions & 0 deletions move_remove_from_playlist.lua
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    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 filename = mp.get_property('playlist/'..pos..'/filename')

    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 '..filename..' from playlist')
    mp.msg.info('Removed '..filename..' from playlist')
    end

    mp.add_key_binding('\\', 'move_up', move_up)
    mp.add_key_binding('x', 'move_down', move_down)
    mp.add_key_binding('z', 'remove_current', remove_current)