History

options: add --osd-playlist-entry

Allow configuring whether to print the media-title, the filename or both (as `<title> (<filename>)`) in show-text ${playlist}, the OSC playlist and in the playlist selector. Showing only titles hides information when files are badly tagged, or when it hides the track numbers of album songs. But showing filenames is not as useful as titles e.g. when playing URLs with media titles. This option lets the user choose which one to show, or show both if switching is inconvenient. The OSC's playlist_media_title script-opt is removed because this option is better since it works everywhere after configuring it once. Closes #11653. Also show the full URLs of playlist entries instead of their basenames in osc.lua and select.lua, consistently with mp_property_playlist(). For simplicity, this just checks if entries contain :// instead of replicating all of mp_is_url().

Guido Cella committed 2 years ago

Commit dc998561 parent d53aa6d8 files · +42 −17Browse files

Unified · Split

8 files
  1. DOCS/interface-changes/show-playlist-titles.txt +2 −0
  2. DOCS/man/options.rst +6 −0
  3. DOCS/man/osc.rst +0 −7
  4. options/options.c +3 −0
  5. options/options.h +1 −0
  6. player/command.c +8 −3
  7. player/lua/osc.lua +11 −6
  8. player/lua/select.lua +11 −1
DOCS/interface-changes/show-playlist-titles.txt+2−0
@@ -0,0 +1,2 @@
1add `--osd-playlist-entry` option
2remove `osc-playlist_media_title` script-opt
DOCS/man/options.rst+6−0
@@ -4392,6 +4392,12 @@ OSD · 4391 unmodified lines
4392 Set the duration of ``osd-playing-msg`` in ms. If this is unset,4392 Set the duration of ``osd-playing-msg`` in ms. If this is unset,
4393 ``osd-playing-msg`` stays on screen for the duration of ``osd-duration``.4393 ``osd-playing-msg`` stays on screen for the duration of ``osd-duration``.
4394 4394
4395``--osd-playlist-entry=<title|filename|both>``
4396 Whether to display the media title, filename, or both. If the
4397 ``media-title`` is not available, it will display only the ``filename``.
4398
4399 Default: ``title``.
4400
4395``--osd-bar-align-x=<-1-1>``4401``--osd-bar-align-x=<-1-1>``
4396 Position of the OSD bar. -1 is far left, 0 is centered, 1 is far right.4402 Position of the OSD bar. -1 is far left, 0 is centered, 1 is far right.
4397 Fractional values (like 0.5) are allowed.4403 Fractional values (like 0.5) are allowed.
DOCS/man/osc.rst+0−7
@@ -408,13 +408,6 @@ Configurable Options · 407 unmodified lines
408 Whether to display the chapters/playlist at the OSD when left-clicking the408 Whether to display the chapters/playlist at the OSD when left-clicking the
409 next/previous OSC buttons, respectively.409 next/previous OSC buttons, respectively.
410 410
411``playlist_media_title``
412 Default: yes
413
414 Whether to display playlist entries in media titles. If set to ``no``, file
415 names are used instead. Note that media title of a file is only available
416 once it has been loaded.
417
418``chapter_fmt``411``chapter_fmt``
419 Default: ``Chapter: %s``412 Default: ``Chapter: %s``
420 413
options/options.c+3−0
@@ -862,6 +862,9 @@ static const m_option_t mp_opts[] = { · 861 unmodified lines
862 {"osd-msg2", OPT_STRING(osd_msg[1]), .flags = UPDATE_OSD},862 {"osd-msg2", OPT_STRING(osd_msg[1]), .flags = UPDATE_OSD},
863 {"osd-msg3", OPT_STRING(osd_msg[2]), .flags = UPDATE_OSD},863 {"osd-msg3", OPT_STRING(osd_msg[2]), .flags = UPDATE_OSD},
864 864
865 {"osd-playlist-entry", OPT_CHOICE(playlist_entry_name,
866 {"title", 0}, {"filename", 1}, {"both", 2})},
867
865 {"video-osd", OPT_BOOL(video_osd), .flags = UPDATE_OSD},868 {"video-osd", OPT_BOOL(video_osd), .flags = UPDATE_OSD},
866 869
867 {"idle", OPT_CHOICE(player_idle_mode,870 {"idle", OPT_CHOICE(player_idle_mode,
options/options.h+1−0
@@ -259,6 +259,7 @@ typedef struct MPOpts { · 258 unmodified lines
259 char *status_msg;259 char *status_msg;
260 char *osd_status_msg;260 char *osd_status_msg;
261 char *osd_msg[3];261 char *osd_msg[3];
262 int playlist_entry_name;
262 int player_idle_mode;263 int player_idle_mode;
263 char **input_commands;264 char **input_commands;
264 bool consolecontrols;265 bool consolecontrols;
player/command.c+8−3
@@ -3262,8 +3262,10 @@ static int mp_property_playlist(void *ctx, struct m_property *prop, · 3261 unmodified lines
3262 3262
3263 for (int n = 0; n < pl->num_entries; n++) {3263 for (int n = 0; n < pl->num_entries; n++) {
3264 struct playlist_entry *e = pl->entries[n];3264 struct playlist_entry *e = pl->entries[n];
3265 res = talloc_strdup_append(res, pl->current == e ? list_current
3266 : list_normal);
3265 char *p = e->title;3267 char *p = e->title;
3266 if (!p) {3268 if (!p || mpctx->opts->playlist_entry_name > 0) {
3267 p = e->filename;3269 p = e->filename;
3268 if (!mp_is_url(bstr0(p))) {3270 if (!mp_is_url(bstr0(p))) {
3269 char *s = mp_basename(e->filename);3271 char *s = mp_basename(e->filename);
@@ -3271,8 +3273,11 @@ static int mp_property_playlist(void *ctx, struct m_property *prop, · 1 unmodified line
3271 p = s;3273 p = s;
3272 }3274 }
3273 }3275 }
3274 const char *m = pl->current == e ? list_current : list_normal;3276 if (!e->title || p == e->title || mpctx->opts->playlist_entry_name == 1) {
3275 res = talloc_asprintf_append(res, "%s%s\n", m, p);3277 res = talloc_asprintf_append(res, "%s\n", p);
3278 } else {
3279 res = talloc_asprintf_append(res, "%s (%s)\n", e->title, p);
3280 }
3276 }3281 }
3277 3282
3278 *(char **)arg =3283 *(char **)arg =
player/lua/osc.lua+11−6
@@ -56,7 +56,6 @@ local user_opts = { · 55 unmodified lines
56 livemarkers = true, -- update seekbar chapter markers on duration change56 livemarkers = true, -- update seekbar chapter markers on duration change
57 chapters_osd = true, -- whether to show chapters OSD on next/prev57 chapters_osd = true, -- whether to show chapters OSD on next/prev
58 playlist_osd = true, -- whether to show playlist OSD on next/prev58 playlist_osd = true, -- whether to show playlist OSD on next/prev
59 playlist_media_title = true, -- whether to use media titles as playlist entry names
60 chapter_fmt = "Chapter: %s", -- chapter print format for seekbar-hover. "no" to disable59 chapter_fmt = "Chapter: %s", -- chapter print format for seekbar-hover. "no" to disable
61 unicodeminus = false, -- whether to use the Unicode minus sign character60 unicodeminus = false, -- whether to use the Unicode minus sign character
62 61
@@ -525,14 +524,20 @@ local function get_playlist() · 462 unmodified lines
525 end524 end
526 525
527 local message = string.format('Playlist [%d/%d]:\n', pos, count)526 local message = string.format('Playlist [%d/%d]:\n', pos, count)
527 local show = mp.get_property_native('osd-playlist-entry')
528 for _, v in ipairs(limlist) do528 for _, v in ipairs(limlist) do
529 local title = v.title529 local entry = v.title
530 local _, filename = utils.split_path(v.filename)530 if not entry or show ~= 'title' then
531 if not user_opts.playlist_media_title or title == nil then531 entry = v.filename
532 title = filename532 if not entry:find("://") then
533 entry = select(2, utils.split_path(entry))
534 end
535 end
536 if v.title and show == 'both' then
537 entry = string.format('%s (%s)', v.title, entry)
533 end538 end
534 message = string.format('%s %s %s\n', message,539 message = string.format('%s %s %s\n', message,
535 (v.current and '●' or '○'), title)540 (v.current and '●' or '○'), entry)
536 end541 end
537 return message542 return message
538end543end
player/lua/select.lua+11−1
@@ -28,9 +28,19 @@ end · 27 unmodified lines
28mp.add_forced_key_binding(nil, "select-playlist", function ()28mp.add_forced_key_binding(nil, "select-playlist", function ()
29 local playlist = {}29 local playlist = {}
30 local default_item30 local default_item
31 local show = mp.get_property_native("osd-playlist-entry")
31 32
32 for i, entry in ipairs(mp.get_property_native("playlist")) do33 for i, entry in ipairs(mp.get_property_native("playlist")) do
33 playlist[i] = select(2, utils.split_path(entry.filename))34 playlist[i] = entry.title
35 if not playlist[i] or show ~= "title" then
36 playlist[i] = entry.filename
37 if not playlist[i]:find("://") then
38 playlist[i] = select(2, utils.split_path(playlist[i]))
39 end
40 end
41 if entry.title and show == "both" then
42 playlist[i] = string.format("%s (%s)", entry.title, playlist[i])
43 end
34 44
35 if entry.playing then45 if entry.playing then
36 default_item = i46 default_item = i

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t