diff --git a/src/components/VideoPlayer.vue b/src/components/VideoPlayer.vue
index 37d569d7..f863cac0 100644
--- a/src/components/VideoPlayer.vue
+++ b/src/components/VideoPlayer.vue
@@ -24,6 +24,14 @@ export default {
return {};
},
},
+ playlist: {
+ type: Object,
+ default: null,
+ },
+ index: {
+ type: Number,
+ default: -1,
+ },
sponsors: {
type: Object,
default: () => {
@@ -38,6 +46,7 @@ export default {
return {
lastUpdate: new Date().getTime(),
initialSeekComplete: false,
+ destroying: false,
};
},
computed: {
@@ -171,9 +180,11 @@ export default {
});
},
deactivated() {
+ this.destroying = true;
this.destroy(true);
},
unmounted() {
+ this.destroying = true;
this.destroy(true);
},
methods: {
@@ -281,6 +292,7 @@ export default {
if (noPrevPlayer)
this.shakaPromise.then(() => {
+ if (this.destroying) return;
this.shaka.polyfill.installAll();
const localPlayer = new this.shaka.Player(videoEl);
@@ -355,13 +367,23 @@ export default {
videoEl.addEventListener("ended", () => {
if (!this.selectedAutoLoop && this.selectedAutoPlay && this.video.relatedStreams.length > 0) {
const params = this.$route.query;
- let url = this.video.relatedStreams[0].url;
+ let url = this.playlist?.relatedStreams?.[this.index]?.url ?? this.video.relatedStreams[0].url;
const searchParams = new URLSearchParams();
for (var param in params)
switch (param) {
case "v":
case "t":
break;
+ case "index":
+ if (this.index < this.playlist.relatedStreams.length)
+ searchParams.set("index", this.index + 1);
+ break;
+ case "list":
+ console.log(this.index);
+ console.log(this.playlist.relatedStreams.length);
+ if (this.index < this.playlist.relatedStreams.length)
+ searchParams.set("list", params.list);
+ break;
default:
searchParams.set(param, params[param]);
break;
diff --git a/src/components/VideoRedirect.vue b/src/components/VideoRedirect.vue
index 38cc5fbe..91763534 100644
--- a/src/components/VideoRedirect.vue
+++ b/src/components/VideoRedirect.vue
@@ -7,7 +7,7 @@ export default {
activated() {
const videoId = this.$route.params.videoId;
if (videoId)
- this.$router.push({
+ this.$router.replace({
path: "/watch",
query: { v: videoId },
});
diff --git a/src/components/WatchVideo.vue b/src/components/WatchVideo.vue
index 01f55bf8..b2470d17 100644
--- a/src/components/WatchVideo.vue
+++ b/src/components/WatchVideo.vue
@@ -4,6 +4,8 @@
ref="videoPlayer"
:video="video"
:sponsors="sponsors"
+ :playlist="playlist"
+ :index="index"
:selected-auto-play="false"
:selected-auto-loop="selectedAutoLoop"
:is-embed="isEmbed"
@@ -18,6 +20,8 @@
ref="videoPlayer"
:video="video"
:sponsors="sponsors"
+ :playlist="playlist"
+ :index="index"
:selected-auto-play="selectedAutoPlay"
:selected-auto-loop="selectedAutoLoop"
/>
@@ -128,6 +132,12 @@
+
{
@@ -307,6 +325,36 @@ export default {
}
});
},
+ async getPlaylistData() {
+ if (this.playlistId) {
+ await this.fetchJson(this.apiUrl() + "/playlists/" + this.playlistId).then(data => {
+ this.playlist = data;
+ });
+ await this.fetchPlaylistPages().then(() => {
+ if (!(this.index >= 0)) {
+ for (let i = 0; i < this.playlist.relatedStreams.length; i++)
+ if (this.playlist.relatedStreams[i].url.substr(-11) == this.getVideoId()) {
+ this.index = i + 1;
+ this.$router.replace({
+ query: { ...this.$route.query, index: this.index },
+ });
+ break;
+ }
+ }
+ });
+ }
+ },
+ async fetchPlaylistPages() {
+ if (this.playlist.nextpage) {
+ await this.fetchJson(this.apiUrl() + "/nextpage/playlists/" + this.playlistId, {
+ nextpage: this.playlist.nextpage,
+ }).then(json => {
+ this.playlist.relatedStreams = this.playlist.relatedStreams.concat(json.relatedStreams);
+ this.playlist.nextpage = json.nextpage;
+ });
+ await this.fetchPlaylistPages();
+ }
+ },
async getSponsors() {
if (this.getPreferenceBoolean("sponsorblock", true))
this.fetchSponsors().then(data => (this.sponsors = data));