From 1b398e99f735e141d88186d4e1a722b9a00f4b9a Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 17 Apr 2014 23:55:04 +0200 Subject: player: add a --loop-file option Unlike --loop, loops a file instead of the playlist. --- DOCS/man/en/options.rst | 6 ++++++ options/options.c | 1 + options/options.h | 1 + player/command.c | 1 + player/playloop.c | 11 +++++++++++ 5 files changed, 20 insertions(+) diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index d46ba0e959..dcf968b437 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -1331,6 +1331,12 @@ OPTIONS disables looping. If several files are specified on command line, the entire playlist is looped. +``--loop-file`` + Loop a single file. The difference to ``--loop=inf`` is that this doesn't + loop the playlist, just the file itself. If the playlist contains only a + single file, the difference between the two option is that this option + performs a seek on loop, instead of reloading the file. + ``--lua=`` Load a Lua script. You can load multiple scripts by separating them with commas (``,``). diff --git a/options/options.c b/options/options.c index eabdeb0520..509e8a7e2b 100644 --- a/options/options.c +++ b/options/options.c @@ -560,6 +560,7 @@ const m_option_t mp_opts[] = { OPT_CHOICE_OR_INT("loop", loop_times, M_OPT_GLOBAL, 2, 10000, ({"no", -1}, {"1", -1}, {"inf", 0})), + OPT_FLAG("loop-file", loop_file, 0), OPT_FLAG("resume-playback", position_resume, 0), OPT_FLAG("save-position-on-quit", position_save_on_quit, 0), diff --git a/options/options.h b/options/options.h index 9bd60c2630..650ee21f5e 100644 --- a/options/options.h +++ b/options/options.h @@ -100,6 +100,7 @@ typedef struct MPOpts { char *stream_capture; char *stream_dump; int loop_times; + int loop_file; int shuffle; int ordered_chapters; char *ordered_chapters_files; diff --git a/player/command.c b/player/command.c index 9834b97b8a..c20e33167a 100644 --- a/player/command.c +++ b/player/command.c @@ -2205,6 +2205,7 @@ static const m_option_t mp_properties[] = { M_OPTION_PROPERTY("osd-level"), M_OPTION_PROPERTY_CUSTOM("osd-scale", property_osd_helper), M_OPTION_PROPERTY("loop"), + M_OPTION_PROPERTY("loop-file"), M_OPTION_PROPERTY_CUSTOM("speed", mp_property_playback_speed), { "filename", mp_property_filename, CONF_TYPE_STRING, 0, 0, 0, NULL }, diff --git a/player/playloop.c b/player/playloop.c index 9ad9debfe1..31e8570589 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -825,6 +825,15 @@ static void handle_sstep(struct MPContext *mpctx) } } +static void handle_loop_file(struct MPContext *mpctx) +{ + struct MPOpts *opts = mpctx->opts; + if (opts->loop_file && mpctx->stop_play == AT_END_OF_FILE) { + set_osd_function(mpctx, OSD_FFW); + queue_seek(mpctx, MPSEEK_ABSOLUTE, get_start_time(mpctx), 0, true); + } +} + static void handle_keep_open(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; @@ -1282,6 +1291,8 @@ void run_playloop(struct MPContext *mpctx) handle_sstep(mpctx); + handle_loop_file(mpctx); + handle_keep_open(mpctx); handle_force_window(mpctx, false); -- cgit v1.2.3