diff options
-rw-r--r-- | DOCS/man/en/input.rst | 7 | ||||
-rw-r--r-- | player/command.c | 13 | ||||
-rw-r--r-- | player/core.h | 1 | ||||
-rw-r--r-- | player/loadfile.c | 1 | ||||
-rw-r--r-- | player/playloop.c | 3 |
5 files changed, 23 insertions, 2 deletions
diff --git a/DOCS/man/en/input.rst b/DOCS/man/en/input.rst index 6b3caa1ec0..d7af45cb61 100644 --- a/DOCS/man/en/input.rst +++ b/DOCS/man/en/input.rst @@ -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``. diff --git a/player/command.c b/player/command.c index 1bf05bf56e..f718cb3147 100644 --- a/player/command.c +++ b/player/command.c @@ -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", diff --git a/player/core.h b/player/core.h index 1d16a0e005..8a8a13cb97 100644 --- a/player/core.h +++ b/player/core.h @@ -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) diff --git a/player/loadfile.c b/player/loadfile.c index ee3deed4a8..f2164d205b 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -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 diff --git a/player/playloop.c b/player/playloop.c index 967963b5dc..20a3104596 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -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); |