mplayer: reshuffle on every loop if --loop and --shuffle are used

See github issue #194.

Unfortunately, this breaks the property that going back in the playlist
always works as expected. This changes, because the playlist_prev
command will work on the reshuffled playlist, instead of loading the
previously played files in order. If this ever becomes an issue, I
might revert this commit.
This commit is contained in:
wm4 2013-08-19 00:50:39 +02:00
parent 2508f38a92
commit 4579cce768
4 changed files with 7 additions and 23 deletions

View File

@ -4473,6 +4473,8 @@ struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction)
struct playlist_entry *next = playlist_get_next(mpctx->playlist, direction);
if (!next && mpctx->opts->loop_times >= 0) {
if (direction > 0) {
if (mpctx->opts->shuffle)
playlist_shuffle(mpctx->playlist);
next = mpctx->playlist->first;
if (next && mpctx->opts->loop_times > 0) {
mpctx->opts->loop_times--;
@ -4733,6 +4735,8 @@ static int mpv_main(int argc, char *argv[])
mpctx->osd = osd_create(opts, mpctx->ass_library);
if (opts->shuffle)
playlist_shuffle(mpctx->playlist);
mpctx->playlist->current = mpctx->playlist->first;
play_files(mpctx);

View File

@ -322,7 +322,6 @@ const m_option_t mp_opts[] = {
// handled in command line parser (parser-mpcmd.c)
{"playlist", NULL, CONF_TYPE_STRING, CONF_NOCFG | M_OPT_MIN, 1, 0, NULL},
{"shuffle", NULL, CONF_TYPE_FLAG, CONF_NOCFG, 0, 0, NULL},
{"{", NULL, CONF_TYPE_STORE, CONF_NOCFG, 0, 0, NULL},
{"}", NULL, CONF_TYPE_STORE, CONF_NOCFG, 0, 0, NULL},
@ -335,6 +334,8 @@ const m_option_t mp_opts[] = {
// handled in mplayer.c (looks at the raw argv[])
{"leak-report", "", CONF_TYPE_STORE, CONF_GLOBAL | CONF_NOCFG },
OPT_FLAG("shuffle", shuffle, CONF_GLOBAL | CONF_NOCFG),
// ------------------------- common options --------------------
OPT_FLAG("quiet", quiet, CONF_GLOBAL),
{"really-quiet", &verbose, CONF_TYPE_STORE, CONF_GLOBAL|CONF_PRE_PARSE, 0, -10, NULL},

View File

@ -81,6 +81,7 @@ typedef struct MPOpts {
char *stream_capture;
char *stream_dump;
int loop_times;
int shuffle;
int ordered_chapters;
int chapter_merge_threshold;
double chapter_seek_threshold;

View File

@ -110,14 +110,6 @@ static bool split_opt(struct parse_state *p)
return false;
}
static bool parse_flag(bstr name, bstr f)
{
struct m_option opt = {NULL, NULL, CONF_TYPE_FLAG, 0, 0, 1, NULL};
int val = 0;
m_option_parse(&opt, name, f, &val);
return !!val;
}
// returns M_OPT_... error code
int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
int argc, char **argv)
@ -125,7 +117,6 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
int ret = M_OPT_UNKNOWN;
int mode = 0;
struct playlist_entry *local_start = NULL;
bool shuffle = false;
int local_params_count = 0;
struct playlist_param *local_params = 0;
@ -190,16 +181,6 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
mode = GLOBAL;
m_config_restore_backups(config);
local_start = NULL;
shuffle = false;
continue;
}
if (bstrcmp0(p.arg, "shuffle") == 0) {
shuffle = parse_flag(p.arg, p.param);
continue;
}
if (bstrcmp0(p.arg, "no-shuffle") == 0) {
shuffle = false;
continue;
}
@ -274,9 +255,6 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
goto err_out;
}
if (shuffle)
playlist_shuffle(files);
ret = 0; // success
err_out: