2022-06-01 03:40:36 +00:00
|
|
|
<template>
|
2022-06-01 18:06:34 +00:00
|
|
|
<div>
|
|
|
|
<!-- <v-progress-linear
|
|
|
|
v-for="segment in segments"
|
|
|
|
:key="segment.UUID"
|
|
|
|
background-opacity="0.5"
|
|
|
|
style="width: 100%; background: #ffffff22"
|
|
|
|
:background-color="segment.category"
|
|
|
|
:buffer-value="(segment.segments[1] / video.duration) * 100"
|
|
|
|
:value="(segment.segments[0] / video.duration) * 100"
|
|
|
|
color="red"
|
|
|
|
height="2"
|
|
|
|
:style="
|
|
|
|
fullscreen
|
|
|
|
? 'width: calc(100% - 2rem); left: 1rem; position: absolute; bottom: 3rem;'
|
|
|
|
: 'width: 100%; left: 0; position: absolute; bottom: 0;'
|
|
|
|
"
|
|
|
|
/> -->
|
|
|
|
</div>
|
2022-06-01 03:40:36 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
video: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-06-01 04:00:54 +00:00
|
|
|
videoid: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-06-01 03:40:36 +00:00
|
|
|
},
|
2022-06-01 18:06:34 +00:00
|
|
|
data: () => ({
|
|
|
|
segments: [],
|
|
|
|
}),
|
2022-06-01 03:40:36 +00:00
|
|
|
mounted() {
|
2022-06-01 06:13:16 +00:00
|
|
|
let vid = this.video;
|
|
|
|
let id = this.videoid;
|
2022-06-01 03:40:36 +00:00
|
|
|
|
2022-06-01 06:13:16 +00:00
|
|
|
vid.addEventListener("loadeddata", (e) => {
|
|
|
|
if (vid.readyState >= 3) {
|
|
|
|
this.$youtube.getSponsorBlock(id, (data) => {
|
2022-06-01 18:06:34 +00:00
|
|
|
console.log("sbreturn", data);
|
|
|
|
if (Array.isArray(data)) {
|
|
|
|
this.segments = data;
|
2022-06-01 03:40:36 +00:00
|
|
|
|
2022-06-01 18:06:34 +00:00
|
|
|
// iterate over data.segments array
|
|
|
|
vid.addEventListener("timeupdate", () => {
|
|
|
|
console.log("sb check", data);
|
|
|
|
data.forEach((sponsor) => {
|
2022-06-01 06:13:16 +00:00
|
|
|
let vidTime = vid.currentTime;
|
2022-06-01 03:40:36 +00:00
|
|
|
|
2022-06-01 18:06:34 +00:00
|
|
|
if (
|
|
|
|
vidTime >= sponsor.segment[0] &&
|
|
|
|
vidTime <= sponsor.segment[1]
|
|
|
|
) {
|
2022-06-01 06:13:16 +00:00
|
|
|
console.log("Skipping the sponsor");
|
|
|
|
vid.currentTime = sponsor.segment[1];
|
|
|
|
}
|
2022-06-01 18:06:34 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2022-06-01 03:40:36 +00:00
|
|
|
}
|
2022-06-01 18:06:34 +00:00
|
|
|
});
|
2022-06-01 03:40:36 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2022-06-01 18:06:34 +00:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.sponsor {
|
|
|
|
color: green;
|
|
|
|
}
|
|
|
|
</style>
|