Commit Graph

3902 Commits

Author SHA1 Message Date
Guido Cella
a06883f79a console.lua: refactor some log code
Rename lines_max to max_lines which is the name used in other functions,
and inline the log_messages variable because its name was confusing.

The math.max(0, lines_max) call was not necessary because console
doesn't crash with 0 or negative max lines.
2025-01-18 12:52:02 +01:00
Guido Cella
ca211b5b88 ytdl_hook.lua: fix start and end conditions
Fixes #13358, fixes fcc67cc6c1.
2025-01-10 14:06:16 +01:00
Guido Cella
7a59a12b76 select.lua: select files with watch later files with g-w
Implement selection of files to resume playing from watch later config
files. Requires --write-filename-in-watch-later-config.
2025-01-05 23:21:50 +01:00
Guido Cella
b530b402bf command: add current-watch-later-dir property
It will be used in the next commit.
2025-01-05 23:21:50 +01:00
Guido Cella
0c3c4a315b select.lua: use mp.msg.warn for unavailable messages 2025-01-05 23:21:50 +01:00
Guido Cella
31d4515157 osc.lua: extract icon_font and icons variables
Define the icon font and icons in variables instead of scattering them
throughout the code to make it easy to change them in the future, or for
forks to change them. Also put the hex values in comments to easily
compare which icons in the font are unused, and explain how to get the
decimal values of the bytes.

Copied from ModernX.
2025-01-05 22:31:59 +01:00
nanahi
72550aa7df console.lua: complete screenshot-raw format parameter 2025-01-05 21:28:57 +01:00
nanahi
ab47e95197 player/screenshot: support more formats for screenshot-raw command
This adds a format parameter to screenshot-raw command which controls
the format of the returned image data. In addition to the bgr0 format,
this adds support for 3 other formats: bgra, rgba, rgba64.

bgra is used by overlay-add command and several window systems.
rgba and rgba64 are used by several GPU APIs and are the formats
returned by the gpu and gpu-next screenshot code, which avoid the need
for further format conversion (see convert_image function).
rgba64 also adds the ability to acquire high bit depth screenshots
for screenshot-raw command.
2025-01-05 21:28:57 +01:00
nanahi
c1237c1d48 player/screenshot: add high depth and format parameters
Add the ability for screenshot_get_rgb to request high depth and other
formats. Will be used for the next commit.
2025-01-05 21:28:57 +01:00
Guido Cella
8ed672ffc8 osc.lua: add slimbottombar and slimtopbar layouts
Add layouts with only the top line of bottombar to be used with images.
2025-01-05 21:24:02 +01:00
Guido Cella
850e03d29f console.lua: add pause_on_open script-opt
Add a script-opt to pause when console opens and unpause when it closes,
disabled by default.

This is particularly useful for selectors that take several seconds to
open so you don't have to guess when to pause, like the subtitle line
selector with embedded subtitles, or my script which lets you select
which lyrics to download after requesting them with curl.
2025-01-05 21:21:32 +01:00
Guido Cella
996e58a738 stats.lua: only reprint stats on video-reconfig when toggled
Make this behave like the comment says it should, because currently when
you show oneshot stats and change file, stats are printed again and hide
--osd-playing-msg. This happens even if you hide the stats by
show-texting something else and change file before the timer expires.
2025-01-05 00:52:49 +01:00
Guido Cella
2e1bc3cf26 osc.lua: allow adding custom buttons 2025-01-05 00:50:35 +01:00
Guido Cella
9db941ff8f osc.lua: add cache_enabled() helper 2025-01-05 00:50:35 +01:00
Guido Cella
0d9763872c stats.lua: fix page 2 and 0 layout
Fixes d84e1b3582.
2025-01-04 20:45:31 +01:00
Guido Cella
d84e1b3582 stats.lua: inherit --osd-shadow-offset
Unlike font and border sizes, the default stats shadow offset is 0 like
--osd-shadow-offset, so it can be inherited from it by default to not
make users configure it in 2 places.

Since 0 and negative numbers are valid offsets, use infinity as the
placeholder for unconfigured values.
2025-01-04 20:07:49 +01:00
Guido Cella
2dcf69655a console.lua: complete playlist-play-index none 2025-01-04 16:52:01 +01:00
Guido Cella
6f8d8a38c4 console.lua: apply --osd-selected-color to selected completions 2025-01-04 16:22:20 +01:00
Kacper Michajłow
96da0cbcbd options: remove the player argument from --media-controls
It is now handled internally by the libmpv profile.

Since `player` was the default option, the impact should be minimal, as it
is uncommon to override the default option with the same value.
yes/no args will function the same way as before this commit.
2025-01-04 15:16:40 +01:00
Kacper Michajłow
59d1dc43b9 various: fix typos 2025-01-04 15:59:49 +02:00
Kacper Michajłow
efcee92d0e various: remove double new line at the end of file 2025-01-04 15:59:49 +02:00
Guido Cella
3f084477ad osc.lua: bind middle clicking play pause to cycle loop-playlist 2025-01-03 21:08:28 +01:00
Guido Cella
c9a99db26c console.lua: don't set the cursor color
This makes no visible difference, only the border color is visible, as
the border is drawn on top of the regular color.
2025-01-03 13:02:10 +01:00
Guido Cella
ab25b3d852 console.lua: inherit --osd-back-color in the cursor
3dcc661de7 made the cursor reset to Default style to not apply the blur,
but \blur0 achieves that without resetting every user style. The cursor
can thus respect the user's --osd-back/shadow-color.
2025-01-03 13:02:10 +01:00
Guido Cella
2ecbe8d83b console.lua: inherit --osd-color in the cursor
Following up 19537a4996, also respect the user-specified color in the
cursor. But the cursor is drawn as a border, so we actually need to use
--osd-color as the border color.
2025-01-03 13:02:10 +01:00
Guido Cella
4e8452aee8 console.lua: inherit --osd-shadow-offset
It was requested in
https://github.com/Samillion/ModernZ/issues/259#issuecomment-2556608926
to make console's shadow offset consistent with --osd-shadow-offset. Not
specifying shadow offsets achieves that. This disables console's shadow
by default but there is no reason console should default to having
shadows but the rest of the OSD shouldn't. Users who want shadows can
enable them in the whole OSD with --osd-shadow-offset. console-specific
shadow_{x,y}_offset script-opts can be added if someone requests them
later.
2025-01-03 12:56:10 +01:00
Guido Cella
f21b3f8f06 console.lua: inherit --osd-back-color
The previous commit changed --osd-back/shadow-color to nearly the same
one console was using. This allows unhardcoding it from there and using
--osd-back-color even with --osd-border-style=outline-and-shadow for
consistency with the rest of the OSD.
2025-01-03 12:18:03 +01:00
Guido Cella
00ff6e5ae2 console.lua: remove useless assignment
The lines in populate_log_with_matches()

if selected_match < first_match_to_print then
    first_match_to_print = selected_match

will set first_match_to_print to 1 even if it is not set here since
handle_edit() sets selected_match = 1.
2025-01-03 11:25:22 +01:00
Guido Cella
f3ed94b74d console.lua: focus the default item after emptying the input line
When console is opened with selectable items and a default item, the
default item is placed at the center. But if you type something and then
clear the line, the first item becomes the selected one. Make it select
the default item and place it in the center in this case too.
2025-01-03 11:25:22 +01:00
Guido Cella
50a3da73b7 select.lua: fix select-edition crash on non-MKVs
In files other than MKVs edition-list is an empty table, not nil. It is
current-edition that is nil.

However nil still needs to be checked to not crash with mpv --idle.
2024-12-31 10:13:38 +01:00
Dudemanguy
a2fe5ee900 player/video: fallback to audio sync logic if VO is not visible
The previous commit put all the pieces in place so now this can be
implemented. Scheduling frames is already written with the assumption
that display sync maybe turn on/off at any time. So all that needs to be
done is check if the VO reports that it is not visible. If so, simply
flip mpctx->display_sync_active to false for that frame and skip the
display sync frame handling. It will become true again when the mpv
window comes back into view.
2024-12-28 16:51:28 +00:00
Kacper Michajłow
7562a798b1 player/osd: use fixed width for vsync-ratio value in status line
Makes status line more stable, without variable width.
2024-12-28 14:33:34 +01:00
Guido Cella
0417218daa console.lua: don't highlight the first completion with mp.input.get
The first completion is highlighted because it is automatically inserted
when pressing Enter, but this isn't the case when the console is used
with mp.input.get, and autoselecting it can be undesirable if you're
entering arbitrary text, unlike with mpv commands where you're usually
choosing from predefined lists. So just don't highlight the first
completion for mp.input clients.
2024-12-28 14:31:44 +01:00
Guido Cella
bd150a4d8d console.lua: keep --osd-{,outline}-color's alpha component for styles
There is no need to override this for colored lines.
2024-12-28 14:13:46 +01:00
Guido Cella
61aa8200ad console.lua: complete clipboard/text 2024-12-28 14:09:07 +01:00
der richter
d389c06646 console.lua: use native clipboard property on macOS 2024-12-24 16:11:45 +01:00
der richter
026f1fb61d clipboard-mac: add macOS clipboard backend 2024-12-24 16:11:45 +01:00
der richter
2b06728df9 command: add ambient-light property
make it observable to make it usable as a replacement for --gamma-auto.
2024-12-21 16:15:44 +01:00
Guido Cella
38c46e4d89 stats.lua: enable runtime script-opt changes
This doesn't work for changing page key script-opts at runtime because
they are used as the indexes of the pages variable, but nothing actually
breaks if you do, it just uses the initial values. This is still useful
for conditionally changing sizes at runtime or for trying out the
osd-box profile by applying it from the console.
2024-12-20 14:54:20 +00:00
Guido Cella
19537a4996 console.lua: inherit --osd-color and --osd-outline-color
Stop overriding the OSD font and outline color in the console input line
and log, except for the lines already in a different color. This allows
configuring the console color and makes it consistent with the rest of
the OSD, like 51bd00c33a did for stats.
2024-12-20 14:54:08 +00:00
Guido Cella
661a380fda console.lua: color the default item with --osd-selected-color
Currently if you change --osd-selected-color the preselected item stays
yellow and can't be changed. Since the default item style was just
chosen from the selected color without the bold, also make the default
item follow --osd-selected-color.

Requested in
https://github.com/Samillion/ModernZ/issues/259#issuecomment-2556608926.
2024-12-20 12:43:34 +01:00
yk
96fad6a0fc ytdl_hook: pass empty proxy value
an empty value to a commandline option usually means that parameter does
not expect anything, but in case of `--proxy`, yt-dlp use an empty value to
disable proxy setting, the empty value need to be passed to `--proxy`
2024-12-17 22:26:46 +02:00
Guido Cella
e52f975842 osc.lua: simplify track ID retrival
When track IDs are auto mp.get_property_native() returns "auto", but
mp.get_property_number() returns nil.

Follow up to 1a558bf5c2 and 897c04afe1.
2024-12-13 18:46:53 +01:00
Guido Cella
5e4b825a48 select.lua: abort edition selection when there's only 1
MKVs have 1 edition by default so don't show an empty edition selection
in that case.
2024-12-13 03:46:03 +01:00
Guido Cella
cac6b663c7 osc.lua: show the full path when right clicking the title
Right clicking playlist arrows already opens the playlist selector so
bind something else to right clicking the title. Make it show the full
path which is useful but not bound anywhere on either the keyboard or
the OSC.
2024-12-12 21:54:44 +01:00
Guido Cella
365a33badd osc.lua: open the playlist selector when right clicking playlist arrows
- It makes more sense to select a playlist entry from the buttons that
  navigate the playlist than from the title
- Provides different bindings for right and middle click
- Mirrors chapter button bindings
2024-12-12 21:54:44 +01:00
Guido Cella
f4a35a0264 osc.lua: move title mbtn script-opts below playlist_next's
Sort mbtn script-opts according to how they are shown to the user in bar
layout instead of how they are defined in osc_init().
2024-12-12 20:35:55 +01:00
Dudemanguy
a7f6460e7e player/audio: get rid of bogus early return in reinit_audio_filters
There is a condition here that is supposed to wait until the ao is
finished playing before it goes through the rest of this function and
actually starts the reinit of the audio chain. This is not needed
however and actually causes a bug. uninit_audio_out already takes the
gapless audio case into account and drains the audio before preceding.
There is no reason to bail here. Additionally, returning early here
actually breaks ao_alsa. ao_alsa is pretty dumb and not able to cope
with changing samplerates. It explictly needs to stop the PCM and then
start it again for it to work. The old code here ensured the ao would
never reinit itself and then would wait forever trying to play samples
with no actual data. Other AOs (pipewire and pulse) seem to be able to
cope with this and reinit themselves in other ways (didn't look in
detail). This change makes no difference for them. Note that in many
cases, this appeared to work on ALSA because there is a high likelihood
that your default audio device will choose a 48 kHz sampling rate and
thus your entire playlist is resampled to 48 kHz which avoids the
bug.

Fixes #15477.
2024-12-11 17:12:22 +00:00
Guido Cella
2dd5bd4cd1 osc.lua: draw box layout below console
console is drawn below the OSC. This looks bad only with layout=box
because there is no user-data/osc/margins so it overlaps with it. Fix it
by using z -1 with box layout.

Follow up to 86d24b0 and 9c22d6b.
2024-12-11 17:51:16 +01:00
Jisu Kim
e2014fb309 osc.lua: add option to enable fade-in effect
Introduced a new `fadein` option to control the fade-in effect for the OSC.
The default value is `no`, which disables fade-in. This option allows users
to enable a fade-in effect when the OSC appears. Updated documentation
accordingly.
2024-12-10 22:41:40 +01:00