2022-02-24 22:29:34 +00:00
< template >
< div >
2022-03-22 01:13:48 +00:00
< video controls autoplay :src = "vidSrc" width = "100%" style = "max-height: 50vh" / >
2022-03-22 07:48:04 +00:00
< v-card v-if = "loaded" class="ml-2 mr-2 background" flat >
2022-03-22 01:13:48 +00:00
< v-card-title class = "mt-2"
style = "padding-top: 0; padding-bottom: 0; font-size: 0.95rem; line-height: 1rem;"
2022-03-21 00:30:59 +00:00
v - text = "title"
/ >
2022-03-20 00:27:45 +00:00
< v-card-text >
2022-03-22 01:13:48 +00:00
< div style = "margin-bottom: 1rem;" > { { views } } views • { { uploaded } } < / div >
2022-03-20 07:24:38 +00:00
2022-03-20 00:27:45 +00:00
<!-- Scrolling Div For Interactions -- - >
2022-03-21 00:30:59 +00:00
< div style = "display: flex; margin-bottom: 1em" >
< v-list-item
v - for = "(item, index) in interactions"
: key = "index"
style = "padding: 0; flex: 0 0 20%"
>
< v-btn
text
2022-03-20 07:24:38 +00:00
class = "vertical-button"
style = "padding: 0; margin: 0"
elevation = "0"
: disabled = "item.disabled"
2022-03-22 05:47:28 +00:00
@ click = "callMethodByName(item.actionName)"
2022-03-20 07:24:38 +00:00
>
2022-03-20 00:27:45 +00:00
< v-icon v-text = "item.icon" / >
2022-03-22 01:13:48 +00:00
< div class = "mt-2" style = "font-size: .66rem;" v-text = "item.value || item.name" / >
2022-03-20 16:13:58 +00:00
< / v-btn >
2022-03-20 00:27:45 +00:00
< / v-list-item >
2022-03-20 13:17:26 +00:00
2022-03-20 16:29:29 +00:00
< v-spacer / >
2022-03-20 18:42:12 +00:00
< v-btn text @ click = "showMore = !showMore" >
< v-icon v-if = "showMore" > mdi -chevron -up < / v-icon >
< v-icon v-else > mdi -chevron -down < / v-icon >
< / v-btn >
2022-03-20 00:27:45 +00:00
< / div >
<!-- End Scrolling Div For Interactions -- - >
2022-03-22 01:13:48 +00:00
<!-- < hr / > -- >
2022-03-20 16:55:25 +00:00
< p > Channel Stuff < / p >
2022-03-20 00:27:45 +00:00
< / v-card-text >
2022-03-21 23:47:11 +00:00
< div v-if = "showMore" class="scroll-y ml-2 mr-2" >
2022-03-21 00:30:59 +00:00
{ { description } }
< / div >
2022-03-20 13:17:26 +00:00
2022-03-22 04:45:15 +00:00
<!-- < v-bottom-sheet
2022-03-21 13:21:18 +00:00
v - model = "showMore"
2022-03-22 00:52:45 +00:00
color = "accent"
2022-03-21 13:21:18 +00:00
style = "z-index: 9999999"
>
< v-sheet style = "padding: 1em" >
< v-btn block @ click = "showMore = !showMore"
> < v-icon > mdi - chevron - down < / v-icon > < / v - b t n
> < br / >
2022-03-20 13:32:28 +00:00
< div class = "scroll-y" >
{ { description } }
< / div >
2022-03-20 18:42:12 +00:00
< / v-sheet >
2022-03-22 04:45:15 +00:00
< / v-bottom-sheet > -- >
2022-03-22 00:52:45 +00:00
<!-- < v-bottom-sheet v-model = "share" color="accent" style="z-index: 9999999" >
2022-03-21 00:30:59 +00:00
< v-sheet style = "padding: 1em" >
2022-03-20 18:42:12 +00:00
< div class = "scroll-y" >
{ { description } }
< / div >
2022-03-20 13:17:26 +00:00
< / v-sheet >
2022-03-21 13:21:18 +00:00
< / v-bottom-sheet > -- >
2022-03-19 06:18:07 +00:00
< / v-card >
2022-03-20 00:27:45 +00:00
2022-03-21 00:27:41 +00:00
< recommended :recommends = "recommends" / >
2022-02-24 22:29:34 +00:00
< / div >
< / template >
2022-03-20 00:27:45 +00:00
< style >
. vertical - button span . v - btn _ _content {
flex - direction : column ;
justify - content : space - around ;
}
< / style >
2022-02-24 22:29:34 +00:00
< script >
2022-03-22 05:47:28 +00:00
import { Share } from "@capacitor/share" ;
2022-02-24 22:29:34 +00:00
export default {
data ( ) {
return {
2022-03-20 00:27:45 +00:00
interactions : [
2022-03-21 00:30:59 +00:00
{
name : "Likes" ,
2022-03-22 01:13:48 +00:00
icon : "mdi-thumb-up-outline" ,
2022-03-22 05:47:28 +00:00
// action: null,
2022-03-21 00:30:59 +00:00
value : this . likes ,
disabled : true ,
} ,
{
name : "Dislikes" ,
2022-03-22 01:13:48 +00:00
icon : "mdi-thumb-down-outline" ,
2022-03-22 05:47:28 +00:00
// action: this.dislike(),
actionName : "dislike" ,
2022-03-21 00:30:59 +00:00
value : this . dislikes ,
disabled : true ,
} ,
{
name : "Share" ,
2022-03-22 01:13:48 +00:00
icon : "mdi-share-outline" ,
2022-03-22 05:47:28 +00:00
// action: this.share(),
actionName : "share" ,
disabled : false ,
2022-03-21 00:30:59 +00:00
} ,
2022-03-20 00:27:45 +00:00
] ,
2022-03-20 13:17:26 +00:00
showMore : false ,
2022-03-22 05:47:28 +00:00
// share: false,
2022-03-20 00:27:45 +00:00
title : null ,
uploaded : null ,
vidSrc : null ,
description : null ,
views : null ,
2022-03-21 00:27:41 +00:00
recommends : [ ] ,
2022-03-22 07:48:04 +00:00
loaded : false ,
2022-03-20 07:24:38 +00:00
} ;
2022-03-13 23:21:41 +00:00
} ,
mounted ( ) {
2022-03-22 07:48:04 +00:00
this . getVideo ( ) ;
} ,
methods : {
getVideo ( ) {
this . likes = 100 ;
this . loaded = false ;
2022-03-20 07:24:38 +00:00
2022-03-22 07:48:04 +00:00
this . $youtube . getVid ( this . $route . query . v ) . then ( ( result ) => {
console . log ( "Video info data" , result ) ;
console . log ( result . availableResolutions ) ;
this . vidSrc =
result . availableResolutions [ result . availableResolutions . length - 1 ] . url ; // Takes the highest available resolution with both video and Audio. Note this will be lower than the actual highest resolution
this . title = result . title ;
this . description = result . metadata . description ; // While this works, I do recommend using the rendered description instead in the future as there are some things a pure string wouldn't work with
this . views = result . metadata . viewCount . toLocaleString ( ) ;
this . likes = result . metadata . likes . toLocaleString ( ) ;
this . uploaded = result . metadata . uploadDate ;
this . interactions [ 0 ] . value = result . metadata . likes ;
this . loaded = true ;
2022-03-21 00:27:41 +00:00
2022-03-22 07:48:04 +00:00
this . recommends = this . $youtube
. viewRecommends ( result . renderedData . recommendations )
. filter ( ( element ) => {
return element !== undefined ;
} ) ;
// .catch((error) => this.$logger("Watch", error, true));
console . log ( "recommendations:" , this . recommends ) ;
} ) ;
2022-03-19 06:18:07 +00:00
2022-03-22 07:48:04 +00:00
this . $youtube . getReturnYoutubeDislike ( this . $route . query . v , ( data ) => {
this . dislikes = data . dislikes . toLocaleString ( ) ;
this . interactions [ 1 ] . value = data . dislikes . toLocaleString ( ) ;
} ) ;
} ,
2022-03-22 05:47:28 +00:00
callMethodByName ( name ) {
// Helper function needed because of issues when directly calling method
// using item.action in the v-for loop
this [ name ] ( ) ;
} ,
2022-03-21 23:47:11 +00:00
dislike ( ) { } ,
2022-03-22 05:47:28 +00:00
async share ( ) {
// this.share = !this.share;
await Share . share ( {
title : this . title ,
text : this . title ,
url : 'https://youtu.be/' + this . $route . query . v ,
dialogTitle : 'Share video' ,
} ) ;
2022-03-22 07:48:04 +00:00
}
2022-03-21 23:47:11 +00:00
} ,
2022-03-22 07:48:04 +00:00
watch : {
2022-03-22 08:00:16 +00:00
// Watch for change in the route query string (in this case, ?v=xxxxxxxx to ?v=yyyyyyyy)
// When change is detected, reset and run getVideo function again
2022-03-22 07:48:04 +00:00
$route : {
deep : true ,
handler ( newRt , oldRt ) {
if ( newRt . query . v != oldRt . query . v ) {
this . vidSrc = "" ;
this . getVideo ( ) ;
}
}
}
}
2022-03-20 07:24:38 +00:00
} ;
2022-02-24 22:29:34 +00:00
< / script >