summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-04-14 22:19:07 +0200
committerwm4 <wm4@nowhere>2014-04-14 22:19:07 +0200
commit60b900487257a3435df02c2b2ce54551c59e4311 (patch)
tree3e9975204ed1403e250604ea60bd5fc14b1b0abf /player
parent1e3e7bb7f4dd87d767c519c73a0ac6e26bd19c15 (diff)
downloadmpv-60b900487257a3435df02c2b2ce54551c59e4311.tar.bz2
mpv-60b900487257a3435df02c2b2ce54551c59e4311.tar.xz
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.
Diffstat (limited to 'player')
-rw-r--r--player/command.c13
-rw-r--r--player/core.h1
-rw-r--r--player/loadfile.c1
-rw-r--r--player/playloop.c3
4 files changed, 16 insertions, 2 deletions
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);