From 329715aeb5f7add422cef6e86115273c5454ec22 Mon Sep 17 00:00:00 2001 From: Holger Frovin Jensen Date: Sun, 5 Dec 2021 22:42:28 +0100 Subject: [PATCH] Fixed autoplay. Added index query. Handled continuations. --- src/components/Player.vue | 4 +++- src/components/Playlist.vue | 7 +++++++ src/components/WatchVideo.vue | 30 ++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/components/Player.vue b/src/components/Player.vue index c6c5974e..64680c49 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -354,7 +354,9 @@ export default { } else searchParams.set(param, index + 1); break; case "list": - if (playlistEnded) searchParams.delete("list"); + if (playlistEnded) { + searchParams.delete("list"); + } break; default: searchParams.set(param, params[param]); diff --git a/src/components/Playlist.vue b/src/components/Playlist.vue index 4f8243bb..7a62e835 100644 --- a/src/components/Playlist.vue +++ b/src/components/Playlist.vue @@ -83,6 +83,13 @@ export default { this.fetchJson(this.apiUrl() + "/nextpage/playlists/" + this.$route.query.list, { nextpage: this.playlist.nextpage, }).then(json => { + json.relatedStreams.forEach((video, i) => { + video.url += + "&list=" + + this.$route.query.list + + "&index=" + + (this.playlist.relatedStreams.length + i + 1); + }); this.playlist.relatedStreams.concat(json.relatedStreams); this.playlist.nextpage = json.nextpage; this.loading = false; diff --git a/src/components/WatchVideo.vue b/src/components/WatchVideo.vue index 291dfb57..5d687f80 100644 --- a/src/components/WatchVideo.vue +++ b/src/components/WatchVideo.vue @@ -357,6 +357,36 @@ export default { this.subscribed = !this.subscribed; }, handleScroll() { + if (this.loading || !this.isPlaylist || !this.playlist.nextpage) return; + if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) { + this.loading = true; + this.fetchJson(this.apiUrl() + "/nextpage/playlists/" + this.$route.query.list, { + nextpage: this.playlist.nextpage, + }).then(json => { + const params = this.$route.query; + const searchParams = new URLSearchParams(); + json.relatedStreams.forEach((video, i) => { + for (var param in params) + switch (param) { + case "v": + case "t": + break; + case "index": + searchParams.set(param, i + 1); + break; + case "list": + break; + default: + searchParams.set(param, params[param]); + break; + } + }); + this.playlist.relatedStreams.concat(json.relatedStreams); + this.playlist.nextpage = json.nextpage; + this.loading = false; + json.relatedStreams.map(stream => this.playlist.relatedStreams.push(stream)); + }); + } if (this.loading || !this.comments || !this.comments.nextpage) return; if (window.innerHeight + window.scrollY >= this.$refs.comments.offsetHeight - window.innerHeight) { this.loading = true;