mpv icon indicating copy to clipboard operation
mpv copied to clipboard

Add Loop button to the player controls

Open marvin1099 opened this issue 7 months ago • 24 comments

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

marvin1099 avatar Mar 30 '25 07:03 marvin1099

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

guidocella avatar Mar 30 '25 08:03 guidocella

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.

marvin1099 avatar Mar 30 '25 09:03 marvin1099

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).

guidocella avatar Mar 30 '25 09:03 guidocella

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 avatar Mar 30 '25 09:03 marvin1099

@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?

marvin1099 avatar Mar 30 '25 09:03 marvin1099

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.

guidocella avatar Mar 30 '25 09:03 guidocella

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.

marvin1099 avatar Mar 30 '25 10:03 marvin1099

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

guidocella avatar Mar 30 '25 10:03 guidocella

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)?

marvin1099 avatar Mar 30 '25 10:03 marvin1099

bind script-binding toggle-shuffle to custom buttons

guidocella avatar Mar 30 '25 10:03 guidocella

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.

marvin1099 avatar Mar 30 '25 11:03 marvin1099

Scripts go in ~/.config/mpv/scripts

guidocella avatar Mar 30 '25 11:03 guidocella

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

marvin1099 avatar Mar 30 '25 11:03 marvin1099

It seems to only work with ttf-symbola-free

guidocella avatar Mar 30 '25 12:03 guidocella

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.

marvin1099 avatar Mar 30 '25 12:03 marvin1099

Do I have to link the ttf file to some other location or is this still the wrong font. I downloaded: aur/ttf-symbola-free 9.00-1

marvin1099 avatar May 25 '25 21:05 marvin1099

It should work by installing it.

guidocella avatar May 26 '25 05:05 guidocella

How do i debug that. Its all installed but it still looks like this:

Image

I added some letters to indicate what is what, but if the emoji would work that would be great.

marvin1099 avatar May 26 '25 09:05 marvin1099

--msg-level=osd/libass=v

guidocella avatar May 26 '25 09:05 guidocella

There seems to be some issue with sans-serif.

[input] Unknown key 'ctlr+F1' at <api>:1
Resuming playback. This behavior can be disabled with --no-resume-playback.
[osd/libass] libass API version: 0x1703000
[osd/libass] libass source: commit: 0.17.3-0-ge46aedea0a0d17da4c4ef49d84b94a7994664ab5-dirty
[osd/libass] Shaper: FriBidi 1.0.15 (SIMPLE) HarfBuzz-ng 11.2.1 (COMPLEX)
[osd/libass] Setting up fonts...
[osd/libass] Using font provider fontconfig
[osd/libass] Done.
● Video  --vid=1  (hevc 1920x1080 60 fps) [default]
● Audio  --aid=1  (aac 2ch 48000 Hz 158 kbps) [default]
[osd/libass] libass API version: 0x1703000
[osd/libass] libass source: commit: 0.17.3-0-ge46aedea0a0d17da4c4ef49d84b94a7994664ab5-dirty
[osd/libass] Shaper: FriBidi 1.0.15 (SIMPLE) HarfBuzz-ng 11.2.1 (COMPLEX)
[osd/libass] Setting up fonts...
[osd/libass] Using font provider fontconfig
[osd/libass] Done.
Using hardware decoding (nvdec).
AO: [pipewire] 48000Hz stereo 2ch floatp
VO: [gpu] 1920x1080 cuda[nv12]
AV: 00:00:02 / 00:11:39 (0%) A-V: -0.000 Cache: 696s/102MB
AV: 00:00:02 / 00:11:39 (0%) A-V:  0.000 Cache: 696s/102MB
[osd/libass] fontselect: (sans-serif, 400, 0) -> /usr/share/fonts/noto/NotoSans-Regular.ttf, 0, NotoSans-Regular
AV: 00:00:02 / 00:11:39 (0%) A-V:  0.000 Cache: 696s/102MB
[osd/libass] Glyph 0x23F1 not found, selecting one more font for (sans-serif, 400, 0)
AV: 00:00:02 / 00:11:39 (0%) A-V:  0.000 Cache: 696s/102MB
[osd/libass] fontselect: failed to find any fallback with glyph 0x23F1 for font: (sans-serif, 400, 0)
AV: 00:00:02 / 00:11:39 (0%) A-V:  0.000 Cache: 696s/102MB
[osd/libass] fontselect: (mpv-osd-symbols, 400, 0) -> mpv-osd-symbols-Regular, 0, mpv-osd-symbols-Regular
AV: 00:00:02 / 00:11:39 (0%) A-V:  0.000 Cache: 696s/102MB
[osd/libass] Glyph 0x1F501 not found, selecting one more font for (sans-serif, 400, 0)
AV: 00:00:02 / 00:11:39 (0%) A-V:  0.000 Cache: 696s/102MB
[osd/libass] fontselect: failed to find any fallback with glyph 0x1F501 for font: (sans-serif, 400, 0)
AV: 00:00:02 / 00:11:39 (0%) A-V:  0.000 Cache: 696s/102MB
[osd/libass] Glyph 0x1F500 not found, selecting one more font for (sans-serif, 400, 0)
AV: 00:00:02 / 00:11:39 (0%) A-V:  0.000 Cache: 696s/102MB
[osd/libass] fontselect: failed to find any fallback with glyph 0x1F500 for font: (sans-serif, 400, 0)

Keeps repeating this

[osd/libass] Glyph 0x23F1 not found, selecting one more font for (sans-serif, 400, 0)
...
[osd/libass] fontselect: failed to find any fallback with glyph 0x23F1 for font: (sans-serif, 400, 0)
...

But with other Glyphs

Do i need to install a font for that one too maby? i have installed:

extra/wqy-zenhei 0.9.45-10 
extra/ttf-opensans 3.003-1 
extra/ttf-fira-sans 1:4.301-2
extra/noto-fonts-emoji 1:2.047-1
extra/noto-fonts-cjk 20240730-1
extra/noto-fonts 1:2025.05.01-1

maybe i need a other one.

Seems i got the correct fonts. Any ideas?

marvin1099 avatar May 26 '25 09:05 marvin1099

It should use Symbola as the sans-serif icon font. I don't know why it doesn't for you. I get

[osd/libass] Glyph 0x1F500 not found, selecting one more font for (sans-serif, 400, 0)
[osd/libass] fontselect: (sans-serif, 400, 0) -> /usr/share/fonts/TTF/Symbola.ttf, 0, Symbola

guidocella avatar May 26 '25 09:05 guidocella

The font Its definitely at the same spot as on your machine. If I use ls /usr/share/fonts/TTF/Symbola.ttf I get:

.rw-r--r-- 3,1M root 30 Mär 14:16  /usr/share/fonts/TTF/Symbola.ttf

Strange, can it be manually defined somehow or is only automatic detection suported. Btw my mpv is on: extra/mpv 1:0.40.0-3

Since im on it, mpv --version gives me:

mpv v0.40.0-dirty Copyright © 2000-2025 mpv/MPlayer/mplayer2 projects
built on May 21 2025 20:53:16
libplacebo version: v7.351.0
FFmpeg version: n7.1.1
FFmpeg library versions:
libavcodec      61.19.101
libavdevice     61.3.100
libavfilter     10.4.100
libavformat     61.7.100
libavutil       59.39.100
libswresample   5.3.100
libswscale      8.3.100

marvin1099 avatar May 26 '25 09:05 marvin1099

Yeah it's in /usr/share/fonts/TTF/Symbola.ttf. You can pass --osd-font=Symbola but it will set it for all OSD text.

guidocella avatar May 26 '25 09:05 guidocella

I ran: mpv --msg-level=osd/libass=v --osd-font=Symbola video.mp4 and got:

[input] Unknown key 'ctlr+F1' at <api>:1
Resuming playback. This behavior can be disabled with --no-resume-playback.
[osd/libass] libass API version: 0x1703000
[osd/libass] libass source: commit: 0.17.3-0-ge46aedea0a0d17da4c4ef49d84b94a7994664ab5-dirty
[osd/libass] Shaper: FriBidi 1.0.15 (SIMPLE) HarfBuzz-ng 11.2.1 (COMPLEX)
[osd/libass] Setting up fonts...
[osd/libass] Using font provider fontconfig
[osd/libass] Done.
● Video  --vid=1  (hevc 1920x1080 60 fps) [default]
● Audio  --aid=1  (aac 2ch 48000 Hz 158 kbps) [default]
[osd/libass] libass API version: 0x1703000
[osd/libass] libass source: commit: 0.17.3-0-ge46aedea0a0d17da4c4ef49d84b94a7994664ab5-dirty
[osd/libass] Shaper: FriBidi 1.0.15 (SIMPLE) HarfBuzz-ng 11.2.1 (COMPLEX)
[osd/libass] Setting up fonts...
[osd/libass] Using font provider fontconfig
[osd/libass] Done.
Using hardware decoding (nvdec).
AO: [pipewire] 48000Hz stereo 2ch floatp
VO: [gpu] 1920x1080 cuda[nv12]
AV: 00:00:12 / 00:11:39 (2%) x3.00 A-V: -0.000 Cache: 686s/100MB
AV: 00:00:12 / 00:11:39 (2%) x3.00 A-V:  0.000 Cache: 686s/100MB
[osd/libass] fontselect: (Symbola, 400, 0) -> /usr/share/fonts/noto/NotoSans-Regular.ttf, 0, NotoSans-Regular
AV: 00:00:12 / 00:11:39 (2%) x3.00 A-V:  0.000 Cache: 686s/100MB
[osd/libass] fontselect: (sans-serif, 400, 0) -> /usr/share/fonts/noto/NotoSans-Regular.ttf, 0, NotoSans-Regular
AV: 00:00:12 / 00:11:39 (2%) x3.00 A-V:  0.000 Cache: 686s/100MB
[osd/libass] fontselect: (mpv-osd-symbols, 400, 0) -> mpv-osd-symbols-Regular, 0, mpv-osd-symbols-Regular
AV: 00:00:12 / 00:11:39 (2%) x3.00 A-V:  0.000 Cache: 686s/100MB
[osd/libass] Glyph 0x23F1 not found, selecting one more font for (Symbola, 400, 0)
AV: 00:00:12 / 00:11:39 (2%) x3.00 A-V:  0.000 Cache: 686s/100MB
[osd/libass] fontselect: failed to find any fallback with glyph 0x23F1 for font: (Symbola, 400, 0)
AV: 00:00:12 / 00:11:39 (2%) x3.00 A-V:  0.000 Cache: 686s/100MB
[osd/libass] Glyph 0x1F500 not found, selecting one more font for (Symbola, 400, 0)
AV: 00:00:12 / 00:11:39 (2%) x3.00 A-V:  0.000 Cache: 686s/100MB
[osd/libass] fontselect: failed to find any fallback with glyph 0x1F500 for font: (Symbola, 400, 0)
AV: 00:00:12 / 00:11:39 (2%) x3.00 A-V:  0.000 Cache: 686s/100MB
[osd/libass] Glyph 0x1F501 not found, selecting one more font for (Symbola, 400, 0)
AV: 00:00:12 / 00:11:39 (2%) x3.00 A-V:  0.000 Cache: 686s/100MB
[osd/libass] fontselect: failed to find any fallback with glyph 0x1F501 for font: (Symbola, 400, 0)

There are more glyph issues down the line. And the emoji is still squares.

Basically still looks like this: Image

The font seems to not have changed in the interface.

marvin1099 avatar May 26 '25 10:05 marvin1099

this shit must be added by default why the fuck is the most important button lacking lol?

ghost avatar Sep 15 '25 15:09 ghost

You can already loop by right clicking the play button.

guidocella avatar Sep 15 '25 15:09 guidocella

https://github.com/mpv-player/mpv/issues/5067 https://github.com/mpv-player/mpv/issues/5068

but i believe it just got overtaken by anime lovers so don't expect much https://github.com/orgs/mpv-player/people

https://github.com/mpv-player/mpv/pull/15031 https://github.com/mpv-player/mpv/issues/15176

shift + l i suppose

ghost avatar Sep 15 '25 15:09 ghost

How do i debug that. Its all installed but it still looks like this:

Image

I added some letters to indicate what is what, but if the emoji would work that would be great.

could you out wheres the bar located at in the source code so i could've made a patcher

ghost avatar Sep 15 '25 15:09 ghost