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().
Unified · Split
| @@ -0,0 +1,2 @@ | ||
| 1 | +add `--osd-playlist-entry` option | |
| 2 | +remove `osc-playlist_media_title` script-opt | |
| @@ -4392,6 +4392,12 @@ OSD · 4391 unmodified lines | ||
| 4392 | 4392 | Set the duration of ``osd-playing-msg`` in ms. If this is unset, |
| 4393 | 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 | 4401 | ``--osd-bar-align-x=<-1-1>`` |
| 4396 | 4402 | Position of the OSD bar. -1 is far left, 0 is centered, 1 is far right. |
| 4397 | 4403 | Fractional values (like 0.5) are allowed. |
| @@ -408,13 +408,6 @@ Configurable Options · 407 unmodified lines | ||
| 408 | 408 | Whether to display the chapters/playlist at the OSD when left-clicking the |
| 409 | 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 | 411 | ``chapter_fmt`` |
| 419 | 412 | Default: ``Chapter: %s`` |
| 420 | 413 | |
| @@ -862,6 +862,9 @@ static const m_option_t mp_opts[] = { · 861 unmodified lines | ||
| 862 | 862 | {"osd-msg2", OPT_STRING(osd_msg[1]), .flags = UPDATE_OSD}, |
| 863 | 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 | 868 | {"video-osd", OPT_BOOL(video_osd), .flags = UPDATE_OSD}, |
| 866 | 869 | |
| 867 | 870 | {"idle", OPT_CHOICE(player_idle_mode, |
| @@ -259,6 +259,7 @@ typedef struct MPOpts { · 258 unmodified lines | ||
| 259 | 259 | char *status_msg; |
| 260 | 260 | char *osd_status_msg; |
| 261 | 261 | char *osd_msg[3]; |
| 262 | + int playlist_entry_name; | |
| 262 | 263 | int player_idle_mode; |
| 263 | 264 | char **input_commands; |
| 264 | 265 | bool consolecontrols; |
| @@ -3262,8 +3262,10 @@ static int mp_property_playlist(void *ctx, struct m_property *prop, · 3261 unmodified lines | ||
| 3262 | 3262 | |
| 3263 | 3263 | for (int n = 0; n < pl->num_entries; n++) { |
| 3264 | 3264 | struct playlist_entry *e = pl->entries[n]; |
| 3265 | + res = talloc_strdup_append(res, pl->current == e ? list_current | |
| 3266 | + : list_normal); | |
| 3265 | 3267 | char *p = e->title; |
| 3266 | − if (!p) { | |
| 3268 | + if (!p || mpctx->opts->playlist_entry_name > 0) { | |
| 3267 | 3269 | p = e->filename; |
| 3268 | 3270 | if (!mp_is_url(bstr0(p))) { |
| 3269 | 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 | 3273 | p = s; |
| 3272 | 3274 | } |
| 3273 | 3275 | } |
| 3274 | − const char *m = pl->current == e ? list_current : list_normal; | |
| 3275 | − res = talloc_asprintf_append(res, "%s%s\n", m, p); | |
| 3276 | + if (!e->title || p == e->title || mpctx->opts->playlist_entry_name == 1) { | |
| 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 | 3283 | *(char **)arg = |
| @@ -56,7 +56,6 @@ local user_opts = { · 55 unmodified lines | ||
| 56 | 56 | livemarkers = true, -- update seekbar chapter markers on duration change |
| 57 | 57 | chapters_osd = true, -- whether to show chapters OSD on next/prev |
| 58 | 58 | 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 | 59 | chapter_fmt = "Chapter: %s", -- chapter print format for seekbar-hover. "no" to disable |
| 61 | 60 | unicodeminus = false, -- whether to use the Unicode minus sign character |
| 62 | 61 | |
| @@ -525,14 +524,20 @@ local function get_playlist() · 462 unmodified lines | ||
| 525 | 524 | end |
| 526 | 525 | |
| 527 | 526 | local message = string.format('Playlist [%d/%d]:\n', pos, count) |
| 527 | + local show = mp.get_property_native('osd-playlist-entry') | |
| 528 | 528 | for _, v in ipairs(limlist) do |
| 529 | − local title = v.title | |
| 530 | − local _, filename = utils.split_path(v.filename) | |
| 531 | − if not user_opts.playlist_media_title or title == nil then | |
| 532 | − title = filename | |
| 529 | + local entry = v.title | |
| 530 | + if not entry or show ~= 'title' then | |
| 531 | + entry = v.filename | |
| 532 | + 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 | 538 | end |
| 534 | 539 | message = string.format('%s %s %s\n', message, |
| 535 | − (v.current and '●' or '○'), title) | |
| 540 | + (v.current and '●' or '○'), entry) | |
| 536 | 541 | end |
| 537 | 542 | return message |
| 538 | 543 | end |
| @@ -28,9 +28,19 @@ end · 27 unmodified lines | ||
| 28 | 28 | mp.add_forced_key_binding(nil, "select-playlist", function () |
| 29 | 29 | local playlist = {} |
| 30 | 30 | local default_item |
| 31 | + local show = mp.get_property_native("osd-playlist-entry") | |
| 31 | 32 | |
| 32 | 33 | 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 | 45 | if entry.playing then |
| 36 | 46 | default_item = i |