0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

mplayer: make --loop loop the playlist instead of each playlist entry

This is simpler and more useful. We could add a new switch for the old
functionality, but that would probably be more confusing than helpful.
When passing only a single file to the command line, this commit
shouldn't change behavior.

(Classic mplayer provided both features by duplicating the loop
functionality in the "playtree".)
This commit is contained in:
wm4 2013-01-09 01:41:02 +01:00
parent c45132cb92
commit f96dd88b41
3 changed files with 11 additions and 33 deletions

View File

@ -1089,7 +1089,8 @@
--loop=<number|inf|no>
Loops playback <number> times. ``inf`` means forever and ``no`` disables
looping.
looping. If several files are specified on command line, the whole playlist
is looped.
--mc=<seconds/frame>
Maximum A-V sync correction per frame (in seconds)

View File

@ -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})),

View File

@ -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) {