Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to prevent autoloading next file (for playlists) #4738

Closed
Keith94 opened this issue Aug 8, 2017 · 19 comments
Closed

How to prevent autoloading next file (for playlists) #4738

Keith94 opened this issue Aug 8, 2017 · 19 comments

Comments

@Keith94
Copy link

Keith94 commented Aug 8, 2017

Opening up playlists gives me the nice ability to use hotkeys to play the next/prev file in the folder manually. But is there some way I can prevent mpv from advancing to the next entry automatically within a playlist? I want to keep the player paused on the last frame, and only advance when I need it to (with simple hotkey).

@occivink
Copy link
Contributor

occivink commented Aug 8, 2017

keep-open=always should work.

@Keith94
Copy link
Author

Keith94 commented Aug 8, 2017

Thank you, this works. My only gripe is that loading the next file keeps the player in a "paused" state. Is there a way to force it to play instead?

@garoto
Copy link
Contributor

garoto commented Aug 8, 2017

reset-on-next-file=pause

@Keith94
Copy link
Author

Keith94 commented Aug 8, 2017

Great! Now combined with autoload script, it behaves almost like MPC-HC. :)

Another question, if the file is paused at the end (on the last frame), can pressing play restart the playback (i.e. automatically seek to the beginning and play)?

@garoto
Copy link
Contributor

garoto commented Aug 8, 2017

You'll need a custom keybind in input.conf to restart playback of the same file:

<keybind> seek 0 absolute-percent ; show-text "Seek to the beginning" ; set pause no

Curiously, I opened an issue with the exact same question back in the day :)

@Keith94
Copy link
Author

Keith94 commented Aug 9, 2017

Cool, that keybind method does the trick. :) Still would be better if mpv handled it automatically.

I don't suppose there's a way to make the "skip to next chapter" keybind also skip to the next file if you're on the last chapter? Or should I request it?

@garoto
Copy link
Contributor

garoto commented Aug 9, 2017

I don't think you can do that with keybinds alone. Take a look at the user-scripts section of the wiki for possible solutions/ideas.

@wiiaboo
Copy link
Member

wiiaboo commented Aug 9, 2017

function chapter_seek(direction)
    local chapters = mp.get_property_number("chapters")
    if chapters == nil then chapters = 0 end
    local chapter  = mp.get_property_number("chapter")
    if chapter == nil then chapter = 0 end
    if chapter+direction < 0 then
        mp.command("playlist_prev")
        mp.commandv("script-message", "osc-playlist")
    elseif chapter+direction >= chapters then
        mp.command("playlist_next")
        mp.commandv("script-message", "osc-playlist")
    else
        mp.commandv("add", "chapter", direction)
        mp.commandv("script-message", "osc-chapterlist")
    end
end
mp.add_key_binding("PGUP", "chapter_next", function() chapter_seek(1) end)
mp.add_key_binding("PGDWN", "chapter_prev", function() chapter_seek(-1) end)

@garoto
Copy link
Contributor

garoto commented Aug 9, 2017

I'm not qualified either way to say, but whatever, it looks very neat to me @wiiaboo

@Keith94
Copy link
Author

Keith94 commented Aug 9, 2017

Hey that works, much obliged @wiiaboo. 😄

Guess that answers all my questions for now. Thnx to all.

@agreselin
Copy link

Hi! Is it possible to make @wiiaboo's function display the OSD bar?

@KonoVitoDa
Copy link

KonoVitoDa commented Dec 15, 2022

function chapter_seek(direction)
    local chapters = mp.get_property_number("chapters")
    if chapters == nil then chapters = 0 end
    local chapter  = mp.get_property_number("chapter")
    if chapter == nil then chapter = 0 end
    if chapter+direction < 0 then
        mp.command("playlist_prev")
        mp.commandv("script-message", "osc-playlist")
    elseif chapter+direction >= chapters then
        mp.command("playlist_next")
        mp.commandv("script-message", "osc-playlist")
    else
        mp.commandv("add", "chapter", direction)
        mp.commandv("script-message", "osc-chapterlist")
    end
end
mp.add_key_binding("PGUP", "chapter_next", function() chapter_seek(1) end)
mp.add_key_binding("PGDWN", "chapter_prev", function() chapter_seek(-1) end)

@wiiaboo Any way to also go to the previous file if "skip to previous chapter" is used very close to the first chapter? Tto make it act like MPC-HC.
And also to hide the "Chapter (unavailable)" message?

@KonoVitoDa
Copy link

How to go to next file if the current file has no chapters?

@Iraito
Copy link

Iraito commented Dec 29, 2023

function chapter_seek(direction)
    local chapters = mp.get_property_number("chapters")
    if chapters == nil then chapters = 0 end
    local chapter  = mp.get_property_number("chapter")
    if chapter == nil then chapter = 0 end
    if chapter+direction < 0 then
        mp.command("playlist_prev")
        mp.commandv("script-message", "osc-playlist")
    elseif chapter+direction >= chapters then
        mp.command("playlist_next")
        mp.commandv("script-message", "osc-playlist")
    else
        mp.commandv("add", "chapter", direction)
        mp.commandv("script-message", "osc-chapterlist")
    end
end
mp.add_key_binding("PGUP", "chapter_next", function() chapter_seek(1) end)
mp.add_key_binding("PGDWN", "chapter_prev", function() chapter_seek(-1) end)

I need help, i'm trying in every way possible to do something simple, pause mpv if it encounters a chapter, that's it, i want to make it so that if mpv encounters a chapter it pauses and i can unpause it with a hotkey, can you help me?

@guidocella
Copy link
Contributor

mp.observe_property('chapter', 'native', function (_, chapter)
    if chapter and chapter > 0 then
        mp.set_property_native('pause', true)
    end
end)

@Iraito
Copy link

Iraito commented Dec 29, 2023

mp.observe_property('chapter', 'native', function (_, chapter)
    if chapter and chapter > 0 then
        mp.set_property_native('pause', true)
    end
end)

Thank you so much!

@KonoVitoDa
Copy link

KonoVitoDa commented Jan 29, 2024

How to make it work for files with no chapters?

EDIT: It already do lol, I was forgetting to edit the keybindings.

@KonoVitoDa
Copy link

function chapter_seek(direction)
    local chapters = mp.get_property_number("chapters")
    if chapters == nil then chapters = 0 end
    local chapter  = mp.get_property_number("chapter")
    if chapter == nil then chapter = 0 end
    if chapter+direction < 0 then
        mp.command("playlist_prev")
        mp.commandv("script-message", "osc-playlist")
    elseif chapter+direction >= chapters then
        mp.command("playlist_next")
        mp.commandv("script-message", "osc-playlist")
    else
        mp.commandv("add", "chapter", direction)
        mp.commandv("script-message", "osc-chapterlist")
    end
end
mp.add_key_binding("PGUP", "chapter_next", function() chapter_seek(1) end)
mp.add_key_binding("PGDWN", "chapter_prev", function() chapter_seek(-1) end)

I need help, i'm trying in every way possible to do something simple, pause mpv if it encounters a chapter, that's it, i want to make it so that if mpv encounters a chapter it pauses and i can unpause it with a hotkey, can you help me?

How to keep the OSD still showing chapter switching messages?

@guidocella
Copy link
Contributor

mp.commandv("osd-msg", "add", "chapter", direction)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants