Fixed autoplay. Added index query. Handled continuations.

This commit is contained in:
Holger Frovin Jensen 2021-12-05 22:42:28 +01:00
parent b83f06cf1f
commit 329715aeb5
3 changed files with 40 additions and 1 deletions

View file

@ -354,7 +354,9 @@ export default {
} else searchParams.set(param, index + 1); } else searchParams.set(param, index + 1);
break; break;
case "list": case "list":
if (playlistEnded) searchParams.delete("list"); if (playlistEnded) {
searchParams.delete("list");
}
break; break;
default: default:
searchParams.set(param, params[param]); searchParams.set(param, params[param]);

View file

@ -83,6 +83,13 @@ export default {
this.fetchJson(this.apiUrl() + "/nextpage/playlists/" + this.$route.query.list, { this.fetchJson(this.apiUrl() + "/nextpage/playlists/" + this.$route.query.list, {
nextpage: this.playlist.nextpage, nextpage: this.playlist.nextpage,
}).then(json => { }).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.relatedStreams.concat(json.relatedStreams);
this.playlist.nextpage = json.nextpage; this.playlist.nextpage = json.nextpage;
this.loading = false; this.loading = false;

View file

@ -357,6 +357,36 @@ export default {
this.subscribed = !this.subscribed; this.subscribed = !this.subscribed;
}, },
handleScroll() { 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 (this.loading || !this.comments || !this.comments.nextpage) return;
if (window.innerHeight + window.scrollY >= this.$refs.comments.offsetHeight - window.innerHeight) { if (window.innerHeight + window.scrollY >= this.$refs.comments.offsetHeight - window.innerHeight) {
this.loading = true; this.loading = true;