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

Usage with betterchapters.lua #12

Open
versedwildcat opened this issue Jun 3, 2022 · 2 comments
Open

Usage with betterchapters.lua #12

versedwildcat opened this issue Jun 3, 2022 · 2 comments

Comments

@versedwildcat
Copy link
Contributor

Hello
First I want to say that this is (in my opinion) by far the best OSC for MPV out there.
You've done a great job with the customization options and especially the documentation.

Quick question, is there any way I could replace the default chapter button behavior to work like betterchapters.lua,
meaning that before the first chapter it would navigate to to the previous playlist item and after the last chapter to the next playlist item

image

PS: there's a small typo in the README, you have it's documentation instead of its documentation

@Zren
Copy link
Owner

Zren commented Jun 3, 2022

Thanks for pointing out the typo.

You can Ctrl+F for ch_next

    --ch_next
    ne = new_element("ch_next", "button")

    ne.visible = have_ch
    ne.enabled = have_ch
    ne.content = tethysIcon_ch_next
    ne.eventresponder["mbtn_left_up"] =
        function ()
            mp.commandv("add", "chapter", 1)
            if user_opts.chapters_osd then
                show_message(get_chapterlist(), 3)
            end
        end
    ne.eventresponder["shift+mbtn_left_up"] =
        function () show_message(get_chapterlist(), 3) end
    ne.eventresponder["mbtn_right_up"] =
        function () show_message(get_chapterlist(), 3) end

If this is what you want:
https://github.com/Argon-/mpv-config/blob/master/scripts/betterchapters.lua

I've tried looking for a way to detect if betterchapters.lua is loaded but can't find anything. Maybe if "chapterplaylist-next" keybinding is registered I could call that keybinding?

Might be easier to just include the function and add a toggle in the config (default=off though).

@versedwildcat
Copy link
Contributor Author

That's exactly what I needed, thanks!

Might be easier to just include the function and add a toggle in the config (default=off though).

This seems like the best course of action
After pasting in the chapter_seek function, I changed these lines

    ne.eventresponder["mbtn_left_up"] =
        function ()
            mp.commandv("add", "chapter", 1)
            if user_opts.chapters_osd then
                show_message(get_chapterlist(), 3)
            end
        end

to this:

    ne.eventresponder["mbtn_left_up"] =
        function () chapter_seek(1) end

And made sure it detected the proper keybinds

local chPrevBinds = grepBindByCmd("^script%-binding(%s+)betterchapters/chapter_prev", {})
local chNextBinds = grepBindByCmd("^script%-binding(%s+)betterchapters/chapter_next", {})

I'd love to see it included by default one day

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

2 participants