mirror of https://github.com/mpv-player/mpv
command: add secondary-sub-start and secondary-sub-end properties
Adds secondary-sub-start and secondary-sub-end properties by setting the current_track index in the m_property's priv variable which later gets accessed in get_times. Also adds a test of the secondary subtitle time properties in tests/subtimes.js bound to 'T'.
This commit is contained in:
parent
383acd41a8
commit
34cfe9d89b
|
@ -2636,12 +2636,18 @@ Property list
|
||||||
subtitles, returns the first start time. If no current subtitle is present
|
subtitles, returns the first start time. If no current subtitle is present
|
||||||
null is returned instead.
|
null is returned instead.
|
||||||
|
|
||||||
|
``secondary-sub-start``
|
||||||
|
Same as ``sub-start``, but for the secondary subtitles.
|
||||||
|
|
||||||
``sub-end``
|
``sub-end``
|
||||||
The current subtitle end time (in seconds). If there's multiple current
|
The current subtitle end time (in seconds). If there's multiple current
|
||||||
subtitles, return the last end time. If no current subtitle is present, or
|
subtitles, return the last end time. If no current subtitle is present, or
|
||||||
if it's present but has unknown or incorrect duration, null is returned
|
if it's present but has unknown or incorrect duration, null is returned
|
||||||
instead.
|
instead.
|
||||||
|
|
||||||
|
``secondary-sub-end``
|
||||||
|
Same as ``sub-end``, but for the secondary subtitles.
|
||||||
|
|
||||||
``playlist-pos`` (RW)
|
``playlist-pos`` (RW)
|
||||||
Current position on playlist. The first entry is on position 0. Writing to
|
Current position on playlist. The first entry is on position 0. Writing to
|
||||||
this property may start playback at the new position.
|
this property may start playback at the new position.
|
||||||
|
|
|
@ -2873,7 +2873,8 @@ static struct sd_times get_times(void *ctx, struct m_property *prop,
|
||||||
{
|
{
|
||||||
struct sd_times res = { .start = MP_NOPTS_VALUE, .end = MP_NOPTS_VALUE };
|
struct sd_times res = { .start = MP_NOPTS_VALUE, .end = MP_NOPTS_VALUE };
|
||||||
MPContext *mpctx = ctx;
|
MPContext *mpctx = ctx;
|
||||||
struct track *track = mpctx->current_track[0][STREAM_SUB];
|
int track_ind = *(int *)prop->priv;
|
||||||
|
struct track *track = mpctx->current_track[track_ind][STREAM_SUB];
|
||||||
struct dec_sub *sub = track ? track->d_sub : NULL;
|
struct dec_sub *sub = track ? track->d_sub : NULL;
|
||||||
double pts = mpctx->playback_pts;
|
double pts = mpctx->playback_pts;
|
||||||
if (!sub || pts == MP_NOPTS_VALUE)
|
if (!sub || pts == MP_NOPTS_VALUE)
|
||||||
|
@ -3674,8 +3675,14 @@ static const struct m_property mp_properties_base[] = {
|
||||||
.priv = (void *)&(const int){SD_TEXT_TYPE_PLAIN}},
|
.priv = (void *)&(const int){SD_TEXT_TYPE_PLAIN}},
|
||||||
{"sub-text-ass", mp_property_sub_text,
|
{"sub-text-ass", mp_property_sub_text,
|
||||||
.priv = (void *)&(const int){SD_TEXT_TYPE_ASS}},
|
.priv = (void *)&(const int){SD_TEXT_TYPE_ASS}},
|
||||||
{"sub-start", mp_property_sub_start},
|
{"sub-start", mp_property_sub_start,
|
||||||
{"sub-end", mp_property_sub_end},
|
.priv = (void *)&(const int){0}},
|
||||||
|
{"secondary-sub-start", mp_property_sub_start,
|
||||||
|
.priv = (void *)&(const int){1}},
|
||||||
|
{"sub-end", mp_property_sub_end,
|
||||||
|
.priv = (void *)&(const int){0}},
|
||||||
|
{"secondary-sub-end", mp_property_sub_end,
|
||||||
|
.priv = (void *)&(const int){1}},
|
||||||
|
|
||||||
{"vf", mp_property_vf},
|
{"vf", mp_property_vf},
|
||||||
{"af", mp_property_af},
|
{"af", mp_property_af},
|
||||||
|
@ -3755,7 +3762,7 @@ static const char *const *const mp_event_property_change[] = {
|
||||||
"estimated-display-fps", "vsync-jitter", "sub-text", "secondary-sub-text",
|
"estimated-display-fps", "vsync-jitter", "sub-text", "secondary-sub-text",
|
||||||
"audio-bitrate", "video-bitrate", "sub-bitrate", "decoder-frame-drop-count",
|
"audio-bitrate", "video-bitrate", "sub-bitrate", "decoder-frame-drop-count",
|
||||||
"frame-drop-count", "video-frame-info", "vf-metadata", "af-metadata",
|
"frame-drop-count", "video-frame-info", "vf-metadata", "af-metadata",
|
||||||
"sub-start", "sub-end"),
|
"sub-start", "sub-end", "secondary-sub-start", "secondary-sub-end"),
|
||||||
E(MP_EVENT_DURATION_UPDATE, "duration"),
|
E(MP_EVENT_DURATION_UPDATE, "duration"),
|
||||||
E(MPV_EVENT_VIDEO_RECONFIG, "video-out-params", "video-params",
|
E(MPV_EVENT_VIDEO_RECONFIG, "video-out-params", "video-params",
|
||||||
"video-format", "video-codec", "video-bitrate", "dwidth", "dheight",
|
"video-format", "video-codec", "video-bitrate", "dwidth", "dheight",
|
||||||
|
|
|
@ -5,3 +5,11 @@ function subtimes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
mp.add_key_binding("t", "subtimes", subtimes);
|
mp.add_key_binding("t", "subtimes", subtimes);
|
||||||
|
|
||||||
|
function secondary_subtimes() {
|
||||||
|
mp.msg.info("secondary-sub-start: " + mp.get_property_number("secondary-sub-start"));
|
||||||
|
mp.msg.info("secondary-sub-end: " + mp.get_property_number("secondary-sub-end"));
|
||||||
|
mp.msg.info("secondary-sub-text: " + mp.get_property_native("secondary-sub-text"));
|
||||||
|
}
|
||||||
|
|
||||||
|
mp.add_key_binding("T", "secondary_subtimes", secondary_subtimes);
|
Loading…
Reference in New Issue