fixed suggested video links from watch page

This commit is contained in:
Ethan 2022-03-22 02:48:04 -05:00
parent efbbd9e6b1
commit 948a058363
1 changed files with 46 additions and 29 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<video controls autoplay :src="vidSrc" width="100%" style="max-height: 50vh" /> <video controls autoplay :src="vidSrc" width="100%" style="max-height: 50vh" />
<v-card class="ml-2 mr-2 background" flat> <v-card v-if="loaded" class="ml-2 mr-2 background" flat>
<v-card-title class="mt-2" <v-card-title class="mt-2"
style="padding-top: 0; padding-bottom: 0; font-size: 0.95rem; line-height: 1rem;" style="padding-top: 0; padding-bottom: 0; font-size: 0.95rem; line-height: 1rem;"
v-text="title" v-text="title"
@ -116,10 +116,16 @@ export default {
description: null, description: null,
views: null, views: null,
recommends: [], recommends: [],
loaded: false,
}; };
}, },
mounted() { mounted() {
this.getVideo();
},
methods: {
getVideo() {
this.likes = 100; this.likes = 100;
this.loaded = false;
this.$youtube.getVid(this.$route.query.v).then((result) => { this.$youtube.getVid(this.$route.query.v).then((result) => {
console.log("Video info data", result); console.log("Video info data", result);
@ -132,6 +138,7 @@ export default {
this.likes = result.metadata.likes.toLocaleString(); this.likes = result.metadata.likes.toLocaleString();
this.uploaded = result.metadata.uploadDate; this.uploaded = result.metadata.uploadDate;
this.interactions[0].value = result.metadata.likes; this.interactions[0].value = result.metadata.likes;
this.loaded = true;
this.recommends = this.$youtube this.recommends = this.$youtube
.viewRecommends(result.renderedData.recommendations) .viewRecommends(result.renderedData.recommendations)
@ -147,7 +154,6 @@ export default {
this.interactions[1].value = data.dislikes.toLocaleString(); this.interactions[1].value = data.dislikes.toLocaleString();
}); });
}, },
methods: {
callMethodByName(name) { callMethodByName(name) {
// Helper function needed because of issues when directly calling method // Helper function needed because of issues when directly calling method
// using item.action in the v-for loop // using item.action in the v-for loop
@ -162,7 +168,18 @@ export default {
url: 'https://youtu.be/' + this.$route.query.v, url: 'https://youtu.be/' + this.$route.query.v,
dialogTitle: 'Share video', dialogTitle: 'Share video',
}); });
}
}, },
}, watch: {
$route: {
deep: true,
handler(newRt, oldRt) {
if (newRt.query.v != oldRt.query.v) {
this.vidSrc = "";
this.getVideo();
}
}
}
}
}; };
</script> </script>