VueTube/NUXT/components/Player/progressbar.vue

62 lines
1.3 KiB
Vue
Raw Normal View History

<template>
<v-progress-linear
2022-06-07 17:16:26 +00:00
style="
z-index: 2;
position: absolute;
background: #ffffff22;
transform: translateY(50%);
"
background-opacity="0.5"
2022-06-07 17:16:26 +00:00
background-color="white"
:buffer-value="buffered"
:value="(currentTime / video.duration) * 100"
2022-06-01 19:02:02 +00:00
:class="!fullscreen || controls ? '' : 'invisible'"
color="primary"
2022-06-07 17:16:26 +00:00
:height="seeking ? 4 : 2"
:style="
fullscreen
2022-06-07 17:16:26 +00:00
? 'width: calc(100% - 2rem); left: 1rem; bottom: 3.25rem;'
: 'width: 100%; left: 0; bottom: 1px;'
"
/>
</template>
<script>
export default {
props: {
video: {
type: Object,
required: true,
},
2022-06-07 17:16:26 +00:00
seeking: {
type: Boolean,
required: true,
},
fullscreen: {
type: Boolean,
required: true,
},
currentTime: {
type: Number,
required: true,
},
2022-06-01 19:05:19 +00:00
controls: {
type: Boolean,
required: true,
},
},
data: () => ({
buffered: 0,
}),
mounted() {
this.video.addEventListener("loadeddata", (e) => {
if (this.video.readyState >= 3) {
this.video.addEventListener("progress", () => {
this.buffered =
(this.video.buffered.end(0) / this.video.duration) * 100;
});
}
});
},
};
</script>