summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/interface-changes.rst1
-rw-r--r--DOCS/man/input.rst6
-rw-r--r--common/playlist.h2
-rw-r--r--demux/demux_playlist.c18
-rw-r--r--player/command.c5
5 files changed, 28 insertions, 4 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index c116e1e005..a92768953e 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -20,6 +20,7 @@ Interface changes
::
--- mpv 0.10.0 will be released ---
+ - add "playlist/N/title" property
- add --video-stereo-mode=no to disable auto-conversions
- add --force-seekable, and change default seekability in some cases
- add vf yadif/vavpp/vdpaupp interlaced-only suboptions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 46aa590bc6..775b45d9e9 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -1530,6 +1530,11 @@ Property list
been unloaded yet; in this case, ``current`` refers to the new
selection. (Since mpv 0.7.0.)
+ ``playlist/N/title``
+ Name of the Nth entry. Only available if the playlist file contains
+ such fields, and only if mpv's parser supports it for the given
+ playlist format.
+
When querying the property with the client API using ``MPV_FORMAT_NODE``,
or with Lua ``mp.get_property_native``, this will return a mpv_node with
the following contents:
@@ -1541,6 +1546,7 @@ Property list
"filename" MPV_FORMAT_STRING
"current" MPV_FORMAT_FLAG (might be missing; since mpv 0.7.0)
"playing" MPV_FORMAT_FLAG (same)
+ "title" MPV_FORMAT_STRING (optional)
``track-list``
List of audio/video/sub tracks, current entry marked. Currently, the raw
diff --git a/common/playlist.h b/common/playlist.h
index 0e571a0ced..be9fd991e2 100644
--- a/common/playlist.h
+++ b/common/playlist.h
@@ -34,6 +34,8 @@ struct playlist_entry {
struct playlist_param *params;
int num_params;
+ char *title;
+
// Set to true if playback didn't seem to work, or if the file could be
// played only for a very short time. This is used to make playlist
// navigation just work in case the user has unplayable files in the
diff --git a/demux/demux_playlist.c b/demux/demux_playlist.c
index 4f48a99b1a..0afda57c6a 100644
--- a/demux/demux_playlist.c
+++ b/demux/demux_playlist.c
@@ -112,11 +112,25 @@ static int parse_m3u(struct pl_parser *p)
ok:
if (p->probing)
return 0;
+ char *title = NULL;
while (line.len || !pl_eof(p)) {
- if (line.len > 0 && !bstr_startswith0(line, "#"))
- pl_add(p, line);
+ if (bstr_eatstart0(&line, "#EXTINF:")) {
+ bstr duration, btitle;
+ if (bstr_split_tok(line, ",", &duration, &btitle) && btitle.len) {
+ talloc_free(title);
+ title = bstrto0(NULL, btitle);
+ }
+ } else if (line.len > 0 && !bstr_startswith0(line, "#")) {
+ char *fn = bstrto0(NULL, line);
+ struct playlist_entry *e = playlist_entry_new(fn);
+ talloc_free(fn);
+ e->title = talloc_steal(e, title);
+ title = NULL;
+ playlist_add(p->pl, e);
+ }
line = bstr_strip(pl_get_line(p));
}
+ talloc_free(title);
return 0;
}
diff --git a/player/command.c b/player/command.c
index c16f804883..0f3e455929 100644
--- a/player/command.c
+++ b/player/command.c
@@ -363,8 +363,6 @@ static int mp_property_media_title(void *ctx, struct m_property *prop,
name = mpctx->opts->media_title;
if (name && name[0])
return m_property_strdup_ro(action, arg, name);
- if (name && name[0])
- return m_property_strdup_ro(action, arg, name);
if (mpctx->master_demuxer) {
name = mp_tags_get_str(mpctx->master_demuxer->metadata, "title");
if (name && name[0])
@@ -373,6 +371,8 @@ static int mp_property_media_title(void *ctx, struct m_property *prop,
if (name && name[0])
return m_property_strdup_ro(action, arg, name);
}
+ if (mpctx->playing && mpctx->playing->title)
+ return m_property_strdup_ro(action, arg, mpctx->playing->title);
return mp_property_filename(ctx, prop, action, arg);
}
@@ -2923,6 +2923,7 @@ static int get_playlist_entry(int item, int action, void *arg, void *ctx)
{"filename", SUB_PROP_STR(e->filename)},
{"current", SUB_PROP_FLAG(1), .unavailable = !current},
{"playing", SUB_PROP_FLAG(1), .unavailable = !playing},
+ {"title", SUB_PROP_STR(e->title), .unavailable = !e->title},
{0}
};