1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-05 21:57:39 +00:00

command: add property to indicate when pausing due to --keep-open

This property is set to "yes" if playback was paused due to --keep-open.

The change notification might not always be perfect; maybe that should
be improved.
This commit is contained in:
wm4 2014-04-14 22:19:07 +02:00
parent 1e3e7bb7f4
commit 60b9004872
5 changed files with 23 additions and 2 deletions

View File

@ -777,6 +777,13 @@ Property list
``paused-for-cache``
Returns ``yes`` when playback is paused because of waiting for the cache.
``eof-reached``
Returns ``yes`` if end of playback was reached, ``no`` otherwise. Note
that this is usually interesting only if ``--keep-open`` is enabled,
since otherwise the player will immediately play the next file (or exit
or enter idle mode), and in these cases the ``eof-reached`` property will
logically be cleared immediately after it's set.
``pts-association-mode`` (RW)
See ``--pts-association-mode``.

View File

@ -991,6 +991,13 @@ static int mp_property_core_idle(m_option_t *prop, int action, void *arg,
return m_property_int_ro(prop, action, arg, mpctx->paused);
}
static int mp_property_eof_reached(m_option_t *prop, int action, void *arg,
void *ctx)
{
MPContext *mpctx = ctx;
return m_property_int_ro(prop, action, arg, mpctx->eof_reached);
}
static int mp_property_cache(m_option_t *prop, int action, void *arg,
void *ctx)
{
@ -2252,6 +2259,8 @@ static const m_option_t mp_properties[] = {
M_OPTION_PROPERTY_CUSTOM("pause", mp_property_pause),
{ "core-idle", mp_property_core_idle, CONF_TYPE_FLAG,
M_OPT_RANGE, 0, 1, NULL },
{ "eof-reached", mp_property_eof_reached, CONF_TYPE_FLAG,
M_OPT_RANGE, 0, 1, NULL },
{ "cache", mp_property_cache, CONF_TYPE_INT },
{ "cache-size", mp_property_cache_size, CONF_TYPE_INT, M_OPT_MIN, 0 },
{ "paused-for-cache", mp_property_paused_for_cache, CONF_TYPE_FLAG,
@ -2389,8 +2398,8 @@ const char **mp_event_property_change[] = {
E(MPV_EVENT_TRACK_SWITCHED, "vid", "video", "aid", "audio", "sid", "sub",
"secondary-sid"),
E(MPV_EVENT_IDLE, "*"),
E(MPV_EVENT_PAUSE, "pause", "paused-on-cache", "core-idle"),
E(MPV_EVENT_UNPAUSE, "pause", "paused-on-cache", "core-idle"),
E(MPV_EVENT_PAUSE, "pause", "paused-on-cache", "core-idle", "eof-reached"),
E(MPV_EVENT_UNPAUSE, "pause", "paused-on-cache", "core-idle", "eof-reached"),
E(MPV_EVENT_TICK, "time-pos", "stream-pos", "stream-time-pos", "avsync",
"percent-pos", "time-remaining", "playtime-remaining"),
E(MPV_EVENT_VIDEO_RECONFIG, "video-out-params", "video-params",

View File

@ -335,6 +335,7 @@ typedef struct MPContext {
int last_dvb_step;
bool paused;
bool eof_reached;
// step this many frames, then pause
int step_frames;
// Counted down each frame, stop playback if 0 is reached. (-1 = disable)

View File

@ -1332,6 +1332,7 @@ goto_reopen_demuxer: ;
mpctx->playing_msg_shown = false;
mpctx->paused = false;
mpctx->paused_for_cache = false;
mpctx->eof_reached = false;
mpctx->seek = (struct seek_params){ 0 };
// If there's a timeline force an absolute seek to initialize state

View File

@ -204,6 +204,7 @@ static void seek_reset(struct MPContext *mpctx, bool reset_ao, bool reset_ac)
mpctx->drop_frame_cnt = 0;
mpctx->dropped_frames = 0;
mpctx->playback_pts = MP_NOPTS_VALUE;
mpctx->eof_reached = false;
#if HAVE_ENCODING
encode_lavc_discontinuity(mpctx->encode_lavc_ctx);
@ -834,6 +835,7 @@ static void handle_keep_open(struct MPContext *mpctx)
if (opts->keep_open && mpctx->stop_play == AT_END_OF_FILE) {
mpctx->stop_play = KEEP_PLAYING;
mpctx->playback_pts = mpctx->last_vo_pts;
mpctx->eof_reached = true;
pause_player(mpctx, PAUSE_BY_KEEP_OPEN);
}
}
@ -1306,6 +1308,7 @@ void idle_loop(struct MPContext *mpctx)
while (mpctx->opts->player_idle_mode && !mpctx->playlist->current
&& mpctx->stop_play != PT_QUIT)
{
mpctx->eof_reached = true;
if (need_reinit) {
mp_notify(mpctx, MPV_EVENT_IDLE, NULL);
handle_force_window(mpctx, true);