summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-06 22:40:55 +0100
committerwm4 <wm4@nowhere>2016-01-06 22:40:55 +0100
commit35f43dfacbe3abc000c1f35e36355613cb7da896 (patch)
treef21cae6345df3d6fa3a75b41444676a95b40ba2a /common
parentb7e179f6d3dc13d76bfdf4d5712e23328219c603 (diff)
downloadmpv-35f43dfacbe3abc000c1f35e36355613cb7da896.tar.bz2
mpv-35f43dfacbe3abc000c1f35e36355613cb7da896.tar.xz
player: make watch later/resume work when "playing" directories
If you do "mpv /bla/", and then branch out into sub-directories using playlist navigation, and then used quit and watch later, then playing the same directory did not resume from the previous point. This was because resuming is based on the path hash, so a path prefix can't be detected when resuming the parent directory. Solve this by writing each path prefix when playing directories is involved. (This includes all parent paths, so interestingly, "mpv /" would also resume in the above example.) Something like this was requested multiple times, and I want it too.
Diffstat (limited to 'common')
-rw-r--r--common/playlist.c12
-rw-r--r--common/playlist.h6
2 files changed, 18 insertions, 0 deletions
diff --git a/common/playlist.c b/common/playlist.c
index 9fd087be67..fe197a8ded 100644
--- a/common/playlist.c
+++ b/common/playlist.c
@@ -206,6 +206,18 @@ void playlist_add_base_path(struct playlist *pl, bstr base_path)
}
}
+// Add redirected_from as new redirect entry to each item in pl.
+void playlist_add_redirect(struct playlist *pl, const char *redirected_from)
+{
+ for (struct playlist_entry *e = pl->first; e; e = e->next) {
+ if (e->num_redirects >= 10) // arbitrary limit for sanity
+ break;
+ char *s = talloc_strdup(e, redirected_from);
+ if (s)
+ MP_TARRAY_APPEND(e, e->redirects, e->num_redirects, s);
+ }
+}
+
// Move all entries from source_pl to pl, appending them after the current entry
// of pl. source_pl will be empty, and all entries have changed ownership to pl.
void playlist_transfer_entries(struct playlist *pl, struct playlist *source_pl)
diff --git a/common/playlist.h b/common/playlist.h
index be9fd991e2..b2861b5230 100644
--- a/common/playlist.h
+++ b/common/playlist.h
@@ -36,6 +36,11 @@ struct playlist_entry {
char *title;
+ // If the user plays a playlist, then the playlist's URL will be appended
+ // as redirect to each entry. (Same for directories etc.)
+ char **redirects;
+ int num_redirects;
+
// Set to true if playback didn't seem to work, or if the file could be
// played only for a very short time. This is used to make playlist
// navigation just work in case the user has unplayable files in the
@@ -88,6 +93,7 @@ void playlist_add_file(struct playlist *pl, const char *filename);
void playlist_shuffle(struct playlist *pl);
struct playlist_entry *playlist_get_next(struct playlist *pl, int direction);
void playlist_add_base_path(struct playlist *pl, bstr base_path);
+void playlist_add_redirect(struct playlist *pl, const char *redirected_from);
void playlist_transfer_entries(struct playlist *pl, struct playlist *source_pl);
void playlist_append_entries(struct playlist *pl, struct playlist *source_pl);