diff options
-rw-r--r-- | DOCS/man/input.rst | 3 | ||||
-rw-r--r-- | player/command.c | 26 |
2 files changed, 23 insertions, 6 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 095a91bb35..f8eb87b065 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -1674,6 +1674,9 @@ Property list Current position on playlist. The first entry is on position 0. Writing to the property will restart playback at the written entry. +``playlist-pos-1`` (RW) + Same as ``playlist-pos``, but 1-based. + ``playlist-count`` Number of total playlist entries. diff --git a/player/command.c b/player/command.c index 7d143ea1f4..db1e3e7703 100644 --- a/player/command.c +++ b/player/command.c @@ -3136,8 +3136,8 @@ static int mp_property_dvb_channel_name(void *ctx, struct m_property *prop, return M_PROPERTY_NOT_IMPLEMENTED; } -static int mp_property_playlist_pos(void *ctx, struct m_property *prop, - int action, void *arg) +static int mp_property_playlist_pos_x(void *ctx, struct m_property *prop, + int action, void *arg, int base) { MPContext *mpctx = ctx; struct playlist *pl = mpctx->playlist; @@ -3149,11 +3149,12 @@ static int mp_property_playlist_pos(void *ctx, struct m_property *prop, int pos = playlist_entry_to_index(pl, pl->current); if (pos < 0) return M_PROPERTY_UNAVAILABLE; - *(int *)arg = pos; + *(int *)arg = pos + base; return M_PROPERTY_OK; } case M_PROPERTY_SET: { - struct playlist_entry *e = playlist_entry_from_index(pl, *(int *)arg); + int pos = *(int *)arg - base; + struct playlist_entry *e = playlist_entry_from_index(pl, pos); if (!e) return M_PROPERTY_ERROR; mp_set_playlist_entry(mpctx, e); @@ -3163,8 +3164,8 @@ static int mp_property_playlist_pos(void *ctx, struct m_property *prop, struct m_option opt = { .type = CONF_TYPE_INT, .flags = CONF_RANGE, - .min = 0, - .max = playlist_entry_count(pl) - 1, + .min = base, + .max = playlist_entry_count(pl) - 1 + base, }; *(struct m_option *)arg = opt; return M_PROPERTY_OK; @@ -3173,6 +3174,18 @@ static int mp_property_playlist_pos(void *ctx, struct m_property *prop, return M_PROPERTY_NOT_IMPLEMENTED; } +static int mp_property_playlist_pos(void *ctx, struct m_property *prop, + int action, void *arg) +{ + return mp_property_playlist_pos_x(ctx, prop, action, arg, 0); +} + +static int mp_property_playlist_pos_1(void *ctx, struct m_property *prop, + int action, void *arg) +{ + return mp_property_playlist_pos_x(ctx, prop, action, arg, 1); +} + static int get_playlist_entry(int item, int action, void *arg, void *ctx) { struct MPContext *mpctx = ctx; @@ -3695,6 +3708,7 @@ static const struct m_property mp_properties[] = { {"playlist", mp_property_playlist}, {"playlist-pos", mp_property_playlist_pos}, + {"playlist-pos-1", mp_property_playlist_pos_1}, M_PROPERTY_ALIAS("playlist-count", "playlist/count"), // Audio |