diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index 9ff664a565..271978786d 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -1089,7 +1089,8 @@ --loop= Loops playback times. ``inf`` means forever and ``no`` disables - looping. + looping. If several files are specified on command line, the whole playlist + is looped. --mc= Maximum A-V sync correction per frame (in seconds) diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h index 9121359b02..cbe705ebc4 100644 --- a/core/cfg-mplayer.h +++ b/core/cfg-mplayer.h @@ -667,7 +667,7 @@ const m_option_t mplayer_opts[]={ {"leak-report", "", CONF_TYPE_PRINT, 0, 0, 0, (void*)1}, OPT_FLAG_CONSTANTS("no-loop", loop_times, 0, 0, -1), - OPT_CHOICE_OR_INT("loop", loop_times, M_OPT_LOCAL, 1, 10000, + OPT_CHOICE_OR_INT("loop", loop_times, CONF_GLOBAL, 1, 10000, ({"no", -1}, {"0", -1}, {"inf", 0})), diff --git a/core/mplayer.c b/core/mplayer.c index 99fdd128d1..17b5404537 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -3511,32 +3511,6 @@ static void run_playloop(struct MPContext *mpctx) } } - /* Looping. */ - if (opts->loop_times >= 0 && (mpctx->stop_play == AT_END_OF_FILE || - mpctx->stop_play == PT_NEXT_ENTRY)) { - mp_msg(MSGT_CPLAYER, MSGL_V, "loop_times = %d\n", opts->loop_times); - - int stop_reason = mpctx->stop_play; - - if (opts->loop_times > 1) - opts->loop_times--; - else if (opts->loop_times == 1) - opts->loop_times = -1; - play_n_frames = play_n_frames_mf; - mpctx->stop_play = 0; - mpctx->seek = (struct seek_params) {0}; - struct seek_params sp = { - .type = MPSEEK_ABSOLUTE, - .amount = rel_time_to_abs(mpctx, opts->play_start, 0), - .exact = 1, - }; - if (seek(mpctx, sp, false) != 0) { - mp_msg(MSGT_CPLAYER, MSGL_ERR, "Can't loop an unseekable file.\n"); - opts->loop_times = -1; - mpctx->stop_play = stop_reason; - } - } - if (mpctx->seek.type) { seek(mpctx, mpctx->seek, false); mpctx->seek = (struct seek_params){ 0 }; @@ -4097,11 +4071,6 @@ goto_enable_cache: ; //==================== START PLAYING ======================= - if (opts->loop_times > 1) - opts->loop_times--; - else if (opts->loop_times == 1) - opts->loop_times = -1; - mp_tmsg(MSGT_CPLAYER, MSGL_V, "Starting playback...\n"); drop_frame_cnt = 0; // fix for multifile fps benchmark @@ -4216,6 +4185,14 @@ static void play_files(struct MPContext *mpctx) if (mpctx->stop_play == PT_NEXT_ENTRY) { new_entry = playlist_get_next(mpctx->playlist, +1); + if (!new_entry && mpctx->opts.loop_times >= 0) { + new_entry = mpctx->playlist->first; + if (mpctx->opts.loop_times > 0) { + mpctx->opts.loop_times--; + if (mpctx->opts.loop_times == 0) + mpctx->opts.loop_times = -1; + } + } } else if (mpctx->stop_play == PT_CURRENT_ENTRY) { new_entry = mpctx->playlist->current; } else if (mpctx->stop_play == PT_RESTART) {