0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-11-09 04:55:07 +00:00
VueTube/NUXT/components/Player/index.vue

181 lines
4.5 KiB
Vue
Raw Normal View History

2022-03-30 12:32:08 +00:00
<template>
2022-05-28 22:28:41 +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-28 01:36:26 +00:00
:src="vidSrc"
2022-05-28 22:28:41 +00:00
style="
transition: 0.15s ease-in-out;
transition-properties: all;
max-height: 100vh;
"
2022-05-28 01:36:26 +00:00
:style="
2022-05-28 22:28:41 +00:00
(controls ? 'filter: brightness(50%);' : 'filter: none;',
contain ? 'object-fit: contain;' : 'object-fit: cover;')
2022-05-28 01:36:26 +00:00
"
2022-04-29 01:44:37 +00:00
/>
2022-05-28 22:28:41 +00:00
<!-- TODO: controls || seeking, take seeking out of <seekbar> component -->
2022-05-28 01:36:26 +00:00
<v-btn
v-if="controls"
2022-05-28 01:36:26 +00:00
text
tile
style="
position: absolute;
top: 0;
left: 0;
width: 50%;
height: 100%;
opacity: 0;
"
2022-05-28 05:16:27 +00:00
@dbclick.stop="$refs.player.currentTime -= $refs.player.duration / 10"
2022-05-28 01:36:26 +00:00
>
<v-icon>mdi-rewind</v-icon>
</v-btn>
<v-btn
v-if="controls"
2022-05-28 01:36:26 +00:00
text
tile
style="
position: absolute;
top: 0;
left: 50%;
width: 50%;
height: 100%;
opacity: 0;
"
2022-05-28 05:16:27 +00:00
@dbclick.stop="$refs.player.currentTime += $refs.player.duration / 10"
2022-05-28 01:36:26 +00:00
>
<v-icon>mdi-fast-forward</v-icon>
</v-btn>
<div
style="transition: opacity 0.15s ease-in-out"
:style="controls ? 'opacity: 1;' : 'opacity: 0; pointer-events: none'"
>
<minimize />
2022-05-28 05:16:27 +00:00
<loop />
<captions />
<close />
2022-05-01 16:42:26 +00:00
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-28 05:16:27 +00:00
<watchtime v-if="$refs.player" :video="$refs.player" />
<quality />
<speed />
<fullscreen
:fullscreen="isFullscreen"
@fullscreen="(controls = $refs.player.paused), handleFullscreenChange()"
2022-05-28 01:36:26 +00:00
/>
</div>
2022-05-28 22:28:41 +00:00
<!-- NOTE: breaks in fullscreen -->
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-05-28 22:04:35 +00:00
:fullscreen="isFullscreen"
:video="$refs.player"
:sources="sources"
/>
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";
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-03-30 12:32:08 +00:00
export default {
components: {
2022-05-28 05:16:27 +00:00
fullscreen,
watchtime,
playpause,
captions,
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-03-30 12:32:08 +00:00
data() {
return {
2022-05-28 01:36:26 +00:00
isFullscreen: false,
controls: false,
2022-05-28 22:28:41 +00:00
contain: true,
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-03-30 12:32:08 +00:00
},
methods: {
2022-05-28 01:36:26 +00:00
handleFullscreenChange() {
2022-05-28 22:04:35 +00:00
// close fullscreen 👇
2022-05-28 01:36:26 +00:00
if (document?.fullscreenElement === this.$refs.vidcontainer) {
2022-05-28 22:04:35 +00:00
const cancellFullScreen =
document.exitFullscreen ||
document.mozCancelFullScreen ||
document.webkitExitFullscreen ||
document.msExitFullscreen;
cancellFullScreen.call(document);
screen.orientation.lock("portrait");
screen.orientation.unlock();
2022-03-30 12:32:08 +00:00
this.$vuetube.navigationBar.show();
2022-05-28 22:04:35 +00:00
this.$vuetube.statusBar.show();
this.isFullscreen = false;
// open fullscreen 👇
2022-05-28 01:36:26 +00:00
} else {
2022-05-28 22:04:35 +00:00
const element = this.$refs.vidcontainer;
const requestFullScreen =
element.requestFullscreen ||
element.webkitRequestFullScreen ||
element.mozRequestFullScreen ||
element.msRequestFullScreen;
requestFullScreen.call(element);
screen.orientation.lock("landscape");
2022-05-28 01:36:26 +00:00
this.$vuetube.navigationBar.hide();
2022-05-28 22:04:35 +00:00
this.$vuetube.statusBar.hide();
this.isFullscreen = true;
2022-03-30 12:32:08 +00:00
}
},
2022-04-29 01:44:37 +00:00
getPlayer() {
return this.$refs.player;
2022-03-30 12:32:08 +00:00
},
},
};
</script>