mirror of https://github.com/mpv-player/mpv
command: add osd-sym-cc property
This allows you to reproduce the OSD symbol.
This commit is contained in:
parent
a173d3a2fb
commit
a522441bbe
|
@ -1296,6 +1296,11 @@ Property list
|
|||
``seekable``
|
||||
Return whether it's generally possible to seek in the current file.
|
||||
|
||||
``osd-sym-cc``
|
||||
Inserts the current OSD symbol as opaque OSD control code (cc). This makes
|
||||
sense with the ``show_text`` command only. The control code is
|
||||
implementation specific and is useless for any other use.
|
||||
|
||||
``options/<name>`` (RW)
|
||||
Read-only access to value of option ``--<name>``. Most options can be
|
||||
changed at runtime by writing to this property. Note that many options
|
||||
|
|
|
@ -2220,6 +2220,15 @@ static int mp_property_osd_par(void *ctx, struct m_property *prop,
|
|||
return m_property_double_ro(action, arg, vo_res.display_par);
|
||||
}
|
||||
|
||||
static int mp_property_osd_sym(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
{
|
||||
MPContext *mpctx = ctx;
|
||||
char temp[20];
|
||||
get_current_osd_sym(mpctx, temp, sizeof(temp));
|
||||
return m_property_strdup_ro(action, arg, temp);
|
||||
}
|
||||
|
||||
/// Video fps (RO)
|
||||
static int mp_property_fps(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
|
@ -2806,6 +2815,8 @@ static const struct m_property mp_properties[] = {
|
|||
{"osd-height", mp_property_osd_h},
|
||||
{"osd-par", mp_property_osd_par},
|
||||
|
||||
{"osd-sym-cc", mp_property_osd_sym},
|
||||
|
||||
// Subs
|
||||
{"sid", mp_property_sub},
|
||||
{"secondary-sid", mp_property_sub2},
|
||||
|
|
|
@ -434,6 +434,7 @@ void set_osd_msg(struct MPContext *mpctx, int level, int time,
|
|||
const char* fmt, ...) PRINTF_ATTRIBUTE(4,5);
|
||||
void set_osd_function(struct MPContext *mpctx, int osd_function);
|
||||
void set_osd_subtitle(struct MPContext *mpctx, const char *text);
|
||||
void get_current_osd_sym(struct MPContext *mpctx, char *buf, size_t buf_size);
|
||||
|
||||
// playloop.c
|
||||
void mp_wait_events(struct MPContext *mpctx, double sleeptime);
|
||||
|
|
21
player/osd.c
21
player/osd.c
|
@ -443,17 +443,8 @@ void set_osd_subtitle(struct MPContext *mpctx, const char *text)
|
|||
term_osd_set_subs(mpctx, text);
|
||||
}
|
||||
|
||||
// sym == mpctx->osd_function
|
||||
static void saddf_osd_function_sym(char **buffer, int sym)
|
||||
void get_current_osd_sym(struct MPContext *mpctx, char *buf, size_t buf_size)
|
||||
{
|
||||
char temp[10];
|
||||
osd_get_function_sym(temp, sizeof(temp), sym);
|
||||
saddf(buffer, "%s ", temp);
|
||||
}
|
||||
|
||||
static void sadd_osd_status(char **buffer, struct MPContext *mpctx, bool full)
|
||||
{
|
||||
bool fractions = mpctx->opts->osd_fractions;
|
||||
int sym = mpctx->osd_function;
|
||||
if (!sym) {
|
||||
if (mpctx->paused_for_cache && !mpctx->opts->pause) {
|
||||
|
@ -464,7 +455,15 @@ static void sadd_osd_status(char **buffer, struct MPContext *mpctx, bool full)
|
|||
sym = OSD_PLAY;
|
||||
}
|
||||
}
|
||||
saddf_osd_function_sym(buffer, sym);
|
||||
osd_get_function_sym(buf, buf_size, sym);
|
||||
}
|
||||
|
||||
static void sadd_osd_status(char **buffer, struct MPContext *mpctx, bool full)
|
||||
{
|
||||
bool fractions = mpctx->opts->osd_fractions;
|
||||
char sym[10];
|
||||
get_current_osd_sym(mpctx, sym, sizeof(sym));
|
||||
saddf(buffer, "%s ", sym);
|
||||
char *custom_msg = mpctx->opts->osd_status_msg;
|
||||
if (custom_msg && full) {
|
||||
char *text = mp_property_expand_escaped_string(mpctx, custom_msg);
|
||||
|
|
Loading…
Reference in New Issue