summaryrefslogtreecommitdiffstats
path: root/core/mplayer.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-02-03 14:54:28 +0100
committerwm4 <wm4@nowhere>2013-02-03 16:52:48 +0100
commit5f28c34962fbbfa7e299c12565b4e5fba9bb21e4 (patch)
tree0072ac6529bc26687746279a809461cda6f538c2 /core/mplayer.c
parent3b37fadc5dedae742cf7d9db69c9656b596d8a7c (diff)
downloadmpv-5f28c34962fbbfa7e299c12565b4e5fba9bb21e4.tar.bz2
mpv-5f28c34962fbbfa7e299c12565b4e5fba9bb21e4.tar.xz
mplayer: make advancing the playlist respect looping
Explicitly advancing the playlist with input commands ("playlist_next") didn't jump back to the first file, if the current file was the last on the playlist and looping was enabled. Fix this and make the behavior with explicit input and playback EOF the same. Also add a minor feature: if looping is enabled, and the current file is the first on the playlist, going back one entry jumps to the last playlist entry (without changing loop count). Fixes #22.
Diffstat (limited to 'core/mplayer.c')
-rw-r--r--core/mplayer.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/core/mplayer.c b/core/mplayer.c
index 51eef24d20..a7761b4da5 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -4191,6 +4191,26 @@ terminate_playback: // don't jump here after ao/vo/getch initialization!
#endif
}
+// Determine the next file to play. Note that if this function returns non-NULL,
+// it can have side-effects and mutate mpctx.
+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) {
+ next = mpctx->playlist->first;
+ if (next && mpctx->opts.loop_times > 0) {
+ mpctx->opts.loop_times--;
+ if (mpctx->opts.loop_times == 0)
+ mpctx->opts.loop_times = -1;
+ }
+ } else {
+ next = mpctx->playlist->last;
+ }
+ }
+ return next;
+}
+
// Play all entries on the playlist, starting from the current entry.
// Return if all done.
static void play_files(struct MPContext *mpctx)
@@ -4210,15 +4230,7 @@ static void play_files(struct MPContext *mpctx)
struct playlist_entry *new_entry = NULL;
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;
- }
- }
+ new_entry = mp_next_file(mpctx, +1);
} else if (mpctx->stop_play == PT_CURRENT_ENTRY) {
new_entry = mpctx->playlist->current;
} else if (mpctx->stop_play == PT_RESTART) {