Skip to content

Add Loop button to the player controls #16154

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

Open
marvin1099 opened this issue Mar 30, 2025 · 15 comments
Open

Add Loop button to the player controls #16154

marvin1099 opened this issue Mar 30, 2025 · 15 comments

Comments

@marvin1099
Copy link

Expected behavior of the wanted feature

It would be great if you could have a loop button in the video player controls.
A shuffle button would also be great.
Mpv supports these functions (at least with the mpris plugin).
Exposing these buttons in the ui seems like a nice thing.

If there is a plugin for these buttons i did not find any.
If there is a way to have these buttons help is appreciated.

Alternative behavior of the wanted feature

No response

Log File

No response

Sample Files

No response

@guidocella
Copy link
Contributor

@marvin1099
Copy link
Author

https://mpv.io/manual/master/#custom-buttons

@guidocella so it is possible with scripts, i see.
Is there any script for this pre-made.
i have never made any scripts for mpv.
Would probably be a difficult task (for me) to make a script for this.

@guidocella
Copy link
Contributor

Those are script-opts, not a script. You just define the desired buttons in script-opts/osc.conf (just gotta put each item on separate lines as the docs are currently formatted incorrectly).

@marvin1099
Copy link
Author

script-opts/osc.conf

In the config folder i presume?
On linux: ~/.config/mpv/script-opts/osc.conf
I will try that.
Sorry that I misunderstood you.

@marvin1099
Copy link
Author

marvin1099 commented Mar 30, 2025

@guidocella Thanks it works but how do i get the emojis to work?
The buttons are just empty squares for me.
Also using the shuffle button won't display any info.
If i use loop if displays "Loop current File: " with "inf" and "no".
Can i get something like that for shuffle too?

@guidocella
Copy link
Contributor

You need a font with monochrome emoji.

For shuffle you would need to write a script that keeps tracks of whether you shuffled and prints different messages.

@marvin1099
Copy link
Author

I see, any font recommendations?
Also do i set the font in the config afterwards, is this how this works?

If you know any scrips for shuffle print please say so,
but otherwise i guess i have to leave this alone.

@guidocella
Copy link
Contributor

I see, any font recommendations?

Symbola

Also do i set the font in the config afterwards, is this how this works?

No need.

If you know any scrips for shuffle print please say so, but otherwise i guess i have to leave this alone.

It is trivial. This will do it

local shuffled

mp.add_key_binding('F1', 'toggle-shuffle', function ()
    if shuffled then
        mp.command('playlist-unshuffle; show-text Unshuffled')
    else
        mp.command('playlist-shuffle; show-text Shuffled')
    end

    shuffled = not shuffled
end)

Change F1 to the desired key and bind script-binding toggle-shuffle to custom buttons

@marvin1099
Copy link
Author

marvin1099 commented Mar 30, 2025

ok thanks, and how do i trigger it with the onscreen (/custom) button?
Just the script name added to "custom_button_2_mbtn_left_command" (shuffle button in osc.conf)?

@guidocella
Copy link
Contributor

bind script-binding toggle-shuffle to custom buttons

@marvin1099
Copy link
Author

Seems to do nothing:
I got in ~/.config/mpv:
toggle-shuffle.lua (with your code)
script-opts/osc.conf (with: custom_button_2_mbtn_left_command=script-binding toggle-shuffle)

F1 wont show text or toggle shuffle and the custom button also triggers nothing.
I probably missunderstood, but i don't know how to fix that.

@guidocella
Copy link
Contributor

Scripts go in ~/.config/mpv/scripts

@marvin1099
Copy link
Author

Jep works now, also i just installed chaotic-aur/otf-symbola
(This added /usr/share/fonts/OTF/Symbola.otf) is that not correct?
Or do i need to restart, a empty square is still displayed for the emojis

@guidocella
Copy link
Contributor

It seems to only work with ttf-symbola-free

@marvin1099
Copy link
Author

ok i installed that, now i got a file at:
/usr/share/fonts/TTF/Symbola.ttf
Emojis are still shown as squares in mpv though.

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

No branches or pull requests

2 participants