2022-03-30 12:32:08 +00:00
|
|
|
<template>
|
2022-05-29 18:13:09 +00:00
|
|
|
<!-- // TODO: down: () => minimize, -->
|
2022-05-28 01:36:26 +00:00
|
|
|
<div
|
|
|
|
ref="vidcontainer"
|
|
|
|
v-touch="{
|
2022-05-28 22:28:41 +00:00
|
|
|
up: () => (contain = false),
|
|
|
|
down: () => (contain = true),
|
2022-05-28 01:36:26 +00:00
|
|
|
}"
|
|
|
|
class="d-flex flex-column"
|
|
|
|
style="position: relative"
|
|
|
|
:style="{
|
|
|
|
borderRadius: $store.state.tweaks.roundWatch
|
|
|
|
? `${$store.state.tweaks.roundTweak / 3}rem`
|
|
|
|
: '0',
|
|
|
|
}"
|
|
|
|
@click="controls = !controls"
|
|
|
|
>
|
2022-04-29 01:44:37 +00:00
|
|
|
<video
|
|
|
|
ref="player"
|
|
|
|
autoplay
|
|
|
|
width="100%"
|
2022-05-29 17:08:21 +00:00
|
|
|
:height="isFullscreen ? '100%' : 'auto'"
|
2022-05-28 01:36:26 +00:00
|
|
|
:src="vidSrc"
|
2022-05-29 17:08:21 +00:00
|
|
|
style="transition: filter 0.15s ease-in-out"
|
|
|
|
:class="controls || seeking ? 'dim' : ''"
|
2022-05-28 22:33:43 +00:00
|
|
|
:style="contain ? 'object-fit: contain;' : 'object-fit: cover;'"
|
2022-04-29 01:44:37 +00:00
|
|
|
/>
|
2022-05-28 01:36:26 +00:00
|
|
|
|
2022-05-29 17:08:21 +00:00
|
|
|
<div
|
|
|
|
v-if="isFullscreen && controls"
|
2022-05-28 01:36:26 +00:00
|
|
|
style="
|
|
|
|
position: absolute;
|
2022-05-29 22:14:00 +00:00
|
|
|
width: calc(100% - 12rem);
|
|
|
|
left: 3rem;
|
|
|
|
top: 0.5rem;
|
2022-05-28 01:36:26 +00:00
|
|
|
"
|
2022-05-29 17:08:21 +00:00
|
|
|
>
|
2022-05-29 22:14:00 +00:00
|
|
|
<h4>{{ video.title }}</h4>
|
|
|
|
<div style="color: #aaa; font-size: 0.75rem">{{ video.channelName }}</div>
|
2022-05-29 17:08:21 +00:00
|
|
|
</div>
|
|
|
|
|
2022-05-29 23:41:42 +00:00
|
|
|
<!-- // TODO: merge the bottom 2 into 1 reusable component -->
|
|
|
|
<v-btn
|
2022-05-29 17:08:21 +00:00
|
|
|
text
|
|
|
|
tile
|
2022-05-29 23:41:42 +00:00
|
|
|
style="
|
|
|
|
opacity: 0;
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 50%;
|
|
|
|
height: 100%;
|
|
|
|
"
|
2022-05-29 23:57:06 +00:00
|
|
|
@dblclick.stop="$refs.player.currentTime -= 10"
|
2022-05-28 01:36:26 +00:00
|
|
|
>
|
|
|
|
<v-icon>mdi-rewind</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
|
|
|
|
<v-btn
|
|
|
|
text
|
|
|
|
tile
|
2022-05-29 23:41:42 +00:00
|
|
|
style="
|
|
|
|
opacity: 0;
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 50%;
|
|
|
|
width: 50%;
|
|
|
|
height: 100%;
|
|
|
|
"
|
2022-05-29 23:57:06 +00:00
|
|
|
@dblclick.stop="$refs.player.currentTime += 10"
|
2022-05-28 01:36:26 +00:00
|
|
|
>
|
|
|
|
<v-icon>mdi-fast-forward</v-icon>
|
2022-05-29 23:41:42 +00:00
|
|
|
</v-btn>
|
2022-05-28 01:36:26 +00:00
|
|
|
|
|
|
|
<div
|
|
|
|
style="transition: opacity 0.15s ease-in-out"
|
2022-06-07 18:29:57 +00:00
|
|
|
:style="
|
|
|
|
controls && !seeking
|
|
|
|
? 'opacity: 1;'
|
|
|
|
: 'opacity: 0; pointer-events: none'
|
|
|
|
"
|
2022-05-28 01:36:26 +00:00
|
|
|
>
|
2022-05-28 22:15:25 +00:00
|
|
|
<minimize />
|
2022-05-28 05:16:27 +00:00
|
|
|
<loop />
|
|
|
|
<captions />
|
2022-05-28 22:15:25 +00:00
|
|
|
<close />
|
2022-05-01 16:42:26 +00:00
|
|
|
|
2022-05-29 23:41:42 +00:00
|
|
|
<v-btn
|
|
|
|
fab
|
|
|
|
text
|
|
|
|
small
|
|
|
|
style="
|
|
|
|
position: absolute;
|
|
|
|
top: calc(50% - 1.25rem);
|
2022-05-29 23:50:00 +00:00
|
|
|
left: calc(50% - 10rem);
|
2022-05-29 23:41:42 +00:00
|
|
|
"
|
|
|
|
color="white"
|
|
|
|
@click.stop="$refs.player.currentTime -= 5"
|
|
|
|
>
|
|
|
|
<v-icon size="1rem">mdi-rewind-5</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
<v-btn
|
|
|
|
fab
|
|
|
|
text
|
|
|
|
style="
|
|
|
|
position: absolute;
|
|
|
|
top: calc(50% - 1.75rem);
|
2022-05-29 23:50:00 +00:00
|
|
|
left: calc(50% - 6.5rem);
|
2022-05-29 23:41:42 +00:00
|
|
|
"
|
|
|
|
color="white"
|
|
|
|
disabled
|
|
|
|
@click.stop=""
|
|
|
|
>
|
|
|
|
<v-icon size="2rem">mdi-skip-previous</v-icon>
|
|
|
|
</v-btn>
|
2022-05-28 05:16:27 +00:00
|
|
|
<playpause
|
2022-05-28 01:36:26 +00:00
|
|
|
v-if="$refs.player"
|
2022-05-28 05:16:27 +00:00
|
|
|
:video="$refs.player"
|
|
|
|
@close="controls = false"
|
2022-05-28 01:36:26 +00:00
|
|
|
/>
|
2022-05-29 23:41:42 +00:00
|
|
|
<v-btn
|
|
|
|
fab
|
|
|
|
text
|
|
|
|
style="
|
|
|
|
position: absolute;
|
|
|
|
top: calc(50% - 1.75rem);
|
|
|
|
left: calc(50% + 3rem);
|
|
|
|
"
|
|
|
|
color="white"
|
|
|
|
disabled
|
|
|
|
@click.stop=""
|
|
|
|
>
|
|
|
|
<v-icon size="2rem">mdi-skip-next</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
<v-btn
|
|
|
|
fab
|
|
|
|
text
|
|
|
|
small
|
|
|
|
style="
|
|
|
|
position: absolute;
|
|
|
|
top: calc(50% - 1.25rem);
|
|
|
|
left: calc(50% + 7rem);
|
|
|
|
"
|
|
|
|
color="white"
|
|
|
|
@click.stop="$refs.player.currentTime += 5"
|
|
|
|
>
|
|
|
|
<v-icon size="1rem">mdi-fast-forward-5</v-icon>
|
|
|
|
</v-btn>
|
2022-05-28 05:16:27 +00:00
|
|
|
|
2022-06-07 18:29:57 +00:00
|
|
|
<watchtime
|
|
|
|
v-if="$refs.player"
|
2022-06-08 16:36:32 +00:00
|
|
|
:current-time="$refs.player.currentTime"
|
|
|
|
:duration="$refs.player.duration"
|
2022-06-07 18:29:57 +00:00
|
|
|
:fullscreen="isFullscreen"
|
|
|
|
/>
|
|
|
|
<v-btn
|
|
|
|
v-if="isFullscreen"
|
|
|
|
fab
|
|
|
|
text
|
|
|
|
small
|
|
|
|
outlined
|
|
|
|
style="position: absolute; bottom: 0.25rem; left: 1rem"
|
|
|
|
color="white"
|
|
|
|
disabled
|
|
|
|
@click.stop=""
|
|
|
|
>
|
|
|
|
<v-icon>mdi-thumb-up-outline</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
<v-btn
|
|
|
|
v-if="isFullscreen"
|
|
|
|
fab
|
|
|
|
text
|
|
|
|
small
|
|
|
|
outlined
|
|
|
|
style="position: absolute; bottom: 0.25rem; left: 4rem"
|
|
|
|
color="white"
|
|
|
|
disabled
|
|
|
|
@click.stop=""
|
|
|
|
>
|
|
|
|
<v-icon>mdi-thumb-down-outline</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
<v-btn
|
|
|
|
v-if="isFullscreen"
|
|
|
|
fab
|
|
|
|
text
|
|
|
|
small
|
|
|
|
outlined
|
|
|
|
style="position: absolute; bottom: 0.25rem; left: 7rem"
|
|
|
|
color="white"
|
|
|
|
disabled
|
|
|
|
@click.stop=""
|
|
|
|
>
|
|
|
|
<v-icon>mdi-share-outline</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
<v-btn
|
|
|
|
v-if="isFullscreen"
|
|
|
|
fab
|
|
|
|
text
|
|
|
|
small
|
|
|
|
outlined
|
|
|
|
style="position: absolute; bottom: 0.25rem; left: 10rem"
|
|
|
|
color="white"
|
|
|
|
disabled
|
|
|
|
@click.stop=""
|
|
|
|
>
|
|
|
|
<v-icon>mdi-plus-box-multiple-outline</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
<v-btn
|
|
|
|
v-if="isFullscreen"
|
|
|
|
fab
|
|
|
|
text
|
|
|
|
small
|
|
|
|
outlined
|
|
|
|
style="position: absolute; bottom: 0.25rem; left: 13rem"
|
|
|
|
color="white"
|
|
|
|
disabled
|
|
|
|
@click.stop=""
|
|
|
|
>
|
|
|
|
<v-icon>mdi-comment-text-outline</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
|
|
|
|
<v-btn
|
|
|
|
v-if="isFullscreen"
|
|
|
|
fab
|
|
|
|
text
|
|
|
|
small
|
|
|
|
style="position: absolute; bottom: 0.25rem; right: 0.25rem"
|
|
|
|
color="white"
|
|
|
|
disabled
|
|
|
|
@click.stop=""
|
|
|
|
>
|
|
|
|
<v-icon>mdi-cards-outline</v-icon>
|
|
|
|
</v-btn>
|
2022-05-29 23:41:42 +00:00
|
|
|
<!-- // TODO: merge the bottom 2 into 1 reusable component -->
|
2022-05-29 18:13:09 +00:00
|
|
|
<quality v-if="$refs.player" :video="$refs.player" :sources="sources" />
|
|
|
|
<speed v-if="$refs.player" :video="$refs.player" />
|
2022-05-28 05:16:27 +00:00
|
|
|
<fullscreen
|
|
|
|
:fullscreen="isFullscreen"
|
|
|
|
@fullscreen="(controls = $refs.player.paused), handleFullscreenChange()"
|
2022-05-28 01:36:26 +00:00
|
|
|
/>
|
2022-06-07 18:29:57 +00:00
|
|
|
<v-btn
|
|
|
|
v-if="isFullscreen"
|
|
|
|
fab
|
|
|
|
text
|
|
|
|
small
|
|
|
|
style="position: absolute; bottom: 0.25rem; right: 0.25rem"
|
|
|
|
color="white"
|
|
|
|
disabled
|
|
|
|
@click.stop=""
|
|
|
|
>
|
|
|
|
<v-icon>mdi-cards-outline</v-icon>
|
|
|
|
</v-btn>
|
2022-05-28 01:36:26 +00:00
|
|
|
</div>
|
2022-06-01 18:06:34 +00:00
|
|
|
<progressbar
|
|
|
|
v-if="$refs.player"
|
|
|
|
:current-time="$refs.player.currentTime"
|
2022-06-08 16:34:52 +00:00
|
|
|
:duration="$refs.player.duration"
|
|
|
|
:fullscreen="isFullscreen"
|
|
|
|
:controls="controls"
|
2022-06-08 15:59:43 +00:00
|
|
|
:buffered="buffered"
|
2022-06-08 16:34:52 +00:00
|
|
|
:seeking="seeking"
|
2022-06-01 18:06:34 +00:00
|
|
|
/>
|
2022-05-28 22:04:35 +00:00
|
|
|
<seekbar
|
2022-05-28 22:28:41 +00:00
|
|
|
v-if="$refs.player"
|
|
|
|
v-show="!isFullscreen || controls"
|
2022-06-08 16:42:03 +00:00
|
|
|
:duration="$refs.player.duration"
|
2022-05-28 22:04:35 +00:00
|
|
|
:fullscreen="isFullscreen"
|
2022-06-08 16:42:03 +00:00
|
|
|
:current-time="progress"
|
2022-05-28 22:04:35 +00:00
|
|
|
:video="$refs.player"
|
2022-05-29 17:08:21 +00:00
|
|
|
:controls="controls"
|
2022-06-08 16:42:03 +00:00
|
|
|
:sources="sources"
|
|
|
|
:seeking="seeking"
|
2022-05-29 17:08:21 +00:00
|
|
|
@seeking="seeking = !seeking"
|
2022-05-28 22:04:35 +00:00
|
|
|
/>
|
2022-06-01 04:00:54 +00:00
|
|
|
<sponsorblock
|
2022-06-08 16:32:04 +00:00
|
|
|
v-if="$refs.player && blocks.length > 0"
|
|
|
|
:duration="$refs.player.duration"
|
2022-06-01 18:35:14 +00:00
|
|
|
:fullscreen="isFullscreen"
|
2022-06-08 16:32:04 +00:00
|
|
|
:controls="controls"
|
|
|
|
:seeking="seeking"
|
2022-06-08 15:59:43 +00:00
|
|
|
:blocks="blocks"
|
2022-06-01 04:00:54 +00:00
|
|
|
/>
|
2022-03-30 12:32:08 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-05-28 05:16:27 +00:00
|
|
|
import loop from "~/components/Player/loop.vue";
|
2022-05-28 22:28:41 +00:00
|
|
|
import close from "~/components/Player/close.vue";
|
2022-05-28 05:16:27 +00:00
|
|
|
import speed from "~/components/Player/speed.vue";
|
2022-05-21 02:01:39 +00:00
|
|
|
import seekbar from "~/components/Player/seekbar.vue";
|
2022-05-28 05:16:27 +00:00
|
|
|
import quality from "~/components/Player/quality.vue";
|
2022-05-28 22:15:25 +00:00
|
|
|
import minimize from "~/components/Player/minimize.vue";
|
2022-05-28 05:16:27 +00:00
|
|
|
import captions from "~/components/Player/captions.vue";
|
|
|
|
import playpause from "~/components/Player/playpause.vue";
|
|
|
|
import watchtime from "~/components/Player/watchtime.vue";
|
|
|
|
import fullscreen from "~/components/Player/fullscreen.vue";
|
2022-06-01 18:06:34 +00:00
|
|
|
import progressbar from "~/components/Player/progressbar.vue";
|
2022-06-01 03:40:36 +00:00
|
|
|
import sponsorblock from "~/components/Player/sponsorblock.vue";
|
2022-03-30 12:32:08 +00:00
|
|
|
export default {
|
2022-04-29 11:49:32 +00:00
|
|
|
components: {
|
2022-06-01 03:40:36 +00:00
|
|
|
sponsorblock,
|
2022-06-01 18:06:34 +00:00
|
|
|
progressbar,
|
2022-05-28 05:16:27 +00:00
|
|
|
fullscreen,
|
|
|
|
watchtime,
|
|
|
|
playpause,
|
|
|
|
captions,
|
2022-05-28 22:15:25 +00:00
|
|
|
minimize,
|
2022-05-28 05:16:27 +00:00
|
|
|
quality,
|
2022-05-01 16:42:26 +00:00
|
|
|
seekbar,
|
2022-05-28 05:16:27 +00:00
|
|
|
speed,
|
2022-05-28 22:28:41 +00:00
|
|
|
close,
|
2022-05-28 05:16:27 +00:00
|
|
|
loop,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
sources: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-05-29 17:08:21 +00:00
|
|
|
video: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-06-01 04:00:54 +00:00
|
|
|
videoid: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-04-29 11:49:32 +00:00
|
|
|
},
|
2022-03-30 12:32:08 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2022-05-28 01:36:26 +00:00
|
|
|
isFullscreen: false,
|
|
|
|
controls: false,
|
2022-05-29 17:08:21 +00:00
|
|
|
seeking: false,
|
2022-05-28 22:28:41 +00:00
|
|
|
contain: true,
|
2022-06-08 15:59:43 +00:00
|
|
|
progress: 0,
|
|
|
|
buffered: 0,
|
|
|
|
watched: 0,
|
|
|
|
blocks: [],
|
2022-04-29 01:44:37 +00:00
|
|
|
vidSrc: "",
|
2022-03-30 12:32:08 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
2022-05-28 01:36:26 +00:00
|
|
|
console.log("sources", this.sources);
|
2022-05-21 02:01:39 +00:00
|
|
|
this.vidSrc = this.sources[this.sources.length - 1].url;
|
2022-06-08 15:59:43 +00:00
|
|
|
let vid = this.$refs.player;
|
|
|
|
|
|
|
|
this.$youtube.getSponsorBlock(this.vidSrc, (data) => {
|
|
|
|
console.log("sbreturn", data);
|
|
|
|
if (Array.isArray(data)) {
|
|
|
|
this.blocks = data;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
vid.addEventListener("loadeddata", (e) => {
|
2022-06-08 16:32:04 +00:00
|
|
|
// TODO: detect video loading state and send this.loading to play button :loading = loading here
|
2022-06-08 15:59:43 +00:00
|
|
|
// console.log(e);
|
|
|
|
if (vid.readyState >= 3) {
|
|
|
|
vid.addEventListener("timeupdate", () => {
|
2022-06-08 16:42:03 +00:00
|
|
|
if (!this.seeking) this.progress = vid.currentTime; // for seekbar
|
2022-06-08 15:59:43 +00:00
|
|
|
|
2022-06-08 16:32:04 +00:00
|
|
|
// console.log("sb check", this.blocks);
|
2022-06-08 15:59:43 +00:00
|
|
|
// iterate over data.segments array
|
2022-06-08 16:42:03 +00:00
|
|
|
// for sponsorblock
|
2022-06-08 15:59:43 +00:00
|
|
|
if (this.blocks.length > 0)
|
|
|
|
this.blocks.forEach((sponsor) => {
|
|
|
|
let vidTime = vid.currentTime;
|
|
|
|
|
|
|
|
if (
|
|
|
|
vidTime >= sponsor.segment[0] &&
|
|
|
|
vidTime <= sponsor.segment[1]
|
|
|
|
) {
|
|
|
|
console.log("Skipping the sponsor");
|
|
|
|
this.$youtube.showToast("Skipped sponsor");
|
|
|
|
vid.currentTime = sponsor.segment[1] + 1;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2022-06-08 16:32:04 +00:00
|
|
|
// TODO: detect video loading state and send this.loading to play button :loading = loading here
|
2022-06-08 15:59:43 +00:00
|
|
|
vid.addEventListener("progress", () => {
|
|
|
|
this.buffered = (vid.buffered.end(0) / vid.duration) * 100;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2022-05-29 17:08:21 +00:00
|
|
|
// TODO: detect orientation change and enter fullscreen
|
2022-03-30 12:32:08 +00:00
|
|
|
},
|
2022-05-28 22:33:43 +00:00
|
|
|
beforeDestroy() {
|
2022-05-29 17:08:21 +00:00
|
|
|
if (this.isFullscreen) this.exitFullscreen();
|
2022-05-28 22:33:43 +00:00
|
|
|
},
|
2022-03-30 12:32:08 +00:00
|
|
|
methods: {
|
2022-05-28 01:36:26 +00:00
|
|
|
handleFullscreenChange() {
|
|
|
|
if (document?.fullscreenElement === this.$refs.vidcontainer) {
|
2022-05-28 22:33:43 +00:00
|
|
|
this.exitFullscreen();
|
2022-05-28 01:36:26 +00:00
|
|
|
} else {
|
2022-05-28 22:33:43 +00:00
|
|
|
this.openFullscreen();
|
2022-03-30 12:32:08 +00:00
|
|
|
}
|
|
|
|
},
|
2022-05-28 22:33:43 +00:00
|
|
|
exitFullscreen() {
|
|
|
|
const cancellFullScreen =
|
|
|
|
document.exitFullscreen ||
|
|
|
|
document.mozCancelFullScreen ||
|
|
|
|
document.webkitExitFullscreen ||
|
|
|
|
document.msExitFullscreen;
|
|
|
|
cancellFullScreen.call(document);
|
|
|
|
screen.orientation.lock("portrait");
|
|
|
|
screen.orientation.unlock();
|
|
|
|
this.$vuetube.navigationBar.show();
|
|
|
|
this.$vuetube.statusBar.show();
|
|
|
|
this.isFullscreen = false;
|
|
|
|
},
|
|
|
|
openFullscreen() {
|
|
|
|
const element = this.$refs.vidcontainer;
|
|
|
|
const requestFullScreen =
|
|
|
|
element.requestFullscreen ||
|
|
|
|
element.webkitRequestFullScreen ||
|
|
|
|
element.mozRequestFullScreen ||
|
|
|
|
element.msRequestFullScreen;
|
|
|
|
requestFullScreen.call(element);
|
|
|
|
screen.orientation.lock("landscape");
|
|
|
|
this.$vuetube.navigationBar.hide();
|
|
|
|
this.$vuetube.statusBar.hide();
|
|
|
|
this.isFullscreen = true;
|
|
|
|
},
|
2022-04-29 01:44:37 +00:00
|
|
|
getPlayer() {
|
|
|
|
return this.$refs.player;
|
2022-03-30 12:32:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2022-05-28 22:33:43 +00:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.dim {
|
2022-05-29 23:50:00 +00:00
|
|
|
filter: brightness(42%);
|
2022-05-28 22:33:43 +00:00
|
|
|
}
|
2022-05-29 17:08:21 +00:00
|
|
|
.invisible {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
2022-05-28 22:33:43 +00:00
|
|
|
</style>
|