summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/options.rst11
-rw-r--r--core/cfg-mplayer.h2
-rw-r--r--core/defaultopts.c1
-rw-r--r--core/mp_core.h3
-rw-r--r--core/mplayer.c14
-rw-r--r--core/options.h1
6 files changed, 31 insertions, 1 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index e30de6a5a9..860c42f18c 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -877,6 +877,17 @@
disable the window manager hints that force the window aspect ratio.
(Ignored in fullscreen mode.)
+--keep-open
+ Do not terminate when playing or seeking beyond the end of the file.
+ Instead, pause the player. When trying to seek beyond end of the file, the
+ player will pause at an arbitrary playback position (or, in corner cases,
+ not redraw the window at all).
+
+ *NOTE*: this option is not respected when using ``--frames``, ``--end``,
+ ``--length``, or when passing a chapter range to ``--chapter``. Explicitly
+ skipping to the next file or skipping beyond the last chapter will terminate
+ playback as well, even if ``--keep-open`` is given.
+
--key-fifo-size=<2-65000>
Specify the size of the FIFO that buffers key events (default: 7). If it
is too small some events may be lost. The main disadvantage of setting it
diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h
index c45d4b42c7..4c7098af2c 100644
--- a/core/cfg-mplayer.h
+++ b/core/cfg-mplayer.h
@@ -380,8 +380,8 @@ const m_option_t common_opts[] = {
OPT_REL_TIME("end", play_end, 0),
OPT_REL_TIME("length", play_length, 0),
- // start paused
OPT_FLAG_ON("pause", start_paused, 0),
+ OPT_FLAG_ON("keep-open", keep_open, 0),
// AVI specific: force non-interleaved mode
{"avi-ni", &force_ni, CONF_TYPE_FLAG, 0, 0, 1, NULL},
diff --git a/core/defaultopts.c b/core/defaultopts.c
index 28ae445388..16fda006c8 100644
--- a/core/defaultopts.c
+++ b/core/defaultopts.c
@@ -39,6 +39,7 @@ void set_default_mplayer_options(struct MPOpts *opts)
.term_osd = 2,
.consolecontrols = 1,
.doubleclick_time = 300,
+ .keep_open = 0,
.audio_id = -1,
.video_id = -1,
.sub_id = -1,
diff --git a/core/mp_core.h b/core/mp_core.h
index 6da6365ab6..0439ca13f5 100644
--- a/core/mp_core.h
+++ b/core/mp_core.h
@@ -215,6 +215,9 @@ typedef struct MPContext {
* (or at least queued to be flipped by VO) */
double video_pts;
double last_seek_pts;
+ // As video_pts, but is not reset when seeking away. (For the very short
+ // period of time until a new frame is decoded and shown.)
+ double last_vo_pts;
// used to prevent hanging in some error cases
unsigned int start_timestamp;
diff --git a/core/mplayer.c b/core/mplayer.c
index 39d5c37543..1946fd6e60 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -3183,6 +3183,7 @@ static void run_playloop(struct MPContext *mpctx)
vo_new_frame_imminent(vo);
struct sh_video *sh_video = mpctx->sh_video;
mpctx->video_pts = sh_video->pts;
+ mpctx->last_vo_pts = mpctx->video_pts;
update_subtitles(mpctx, sh_video->pts);
update_osd_msg(mpctx);
draw_osd(mpctx);
@@ -3369,6 +3370,18 @@ static void run_playloop(struct MPContext *mpctx)
queue_seek(mpctx, MPSEEK_RELATIVE, step_sec, 0);
}
+ if (opts->keep_open && mpctx->stop_play == AT_END_OF_FILE) {
+ mpctx->stop_play = KEEP_PLAYING;
+ pause_player(mpctx);
+ if (mpctx->video_out && !mpctx->video_out->hasframe) {
+ // Force screen refresh to make OSD usable
+ double seek_to = mpctx->last_vo_pts;
+ if (seek_to == MP_NOPTS_VALUE)
+ seek_to = 0; // arbitrary default
+ queue_seek(mpctx, MPSEEK_ABSOLUTE, seek_to, 1);
+ }
+ }
+
/* Looping. */
if (opts->loop_times >= 0 && (mpctx->stop_play == AT_END_OF_FILE ||
mpctx->stop_play == PT_NEXT_ENTRY)) {
@@ -4019,6 +4032,7 @@ goto_enable_cache:
mpctx->drop_message_shown = 0;
mpctx->restart_playback = true;
mpctx->video_pts = 0;
+ mpctx->last_vo_pts = MP_NOPTS_VALUE;
mpctx->last_seek_pts = 0;
mpctx->hrseek_active = false;
mpctx->hrseek_framedrop = false;
diff --git a/core/options.h b/core/options.h
index 0ceef0f25a..50f5d10bbf 100644
--- a/core/options.h
+++ b/core/options.h
@@ -77,6 +77,7 @@ typedef struct MPOpts {
struct m_rel_time play_end;
struct m_rel_time play_length;
int start_paused;
+ int keep_open;
int audio_id;
int video_id;
int sub_id;