2022-06-01 03:40:36 +00:00
|
|
|
<template>
|
2022-06-01 18:06:34 +00:00
|
|
|
<div>
|
2022-06-01 18:35:14 +00:00
|
|
|
<v-progress-linear
|
|
|
|
v-for="block in blocks"
|
|
|
|
:key="block.UUID"
|
|
|
|
:buffer-value="(block.segment[1] / video.duration) * 100"
|
|
|
|
:value="(block.segment[0] / video.duration) * 100"
|
|
|
|
style="
|
|
|
|
z-index: 4;
|
|
|
|
width: 100%;
|
|
|
|
background: transparent;
|
|
|
|
pointer-events: none;
|
|
|
|
"
|
|
|
|
background-color="white"
|
|
|
|
background-opacity="1"
|
|
|
|
color="transparent"
|
2022-06-01 18:06:34 +00:00
|
|
|
height="2"
|
|
|
|
:style="
|
|
|
|
fullscreen
|
|
|
|
? 'width: calc(100% - 2rem); left: 1rem; position: absolute; bottom: 3rem;'
|
|
|
|
: 'width: 100%; left: 0; position: absolute; bottom: 0;'
|
|
|
|
"
|
2022-06-01 18:35:14 +00:00
|
|
|
/>
|
2022-06-01 18:06:34 +00:00
|
|
|
</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 18:35:14 +00:00
|
|
|
fullscreen: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-06-01 03:40:36 +00:00
|
|
|
},
|
2022-06-01 18:06:34 +00:00
|
|
|
data: () => ({
|
2022-06-01 18:35:14 +00:00
|
|
|
blocks: [],
|
2022-06-01 18:06:34 +00:00
|
|
|
}),
|
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)) {
|
2022-06-01 18:35:14 +00:00
|
|
|
this.blocks = 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", () => {
|
2022-06-01 18:35:14 +00:00
|
|
|
// console.log("sb check", data);
|
2022-06-01 18:06:34 +00:00
|
|
|
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] &&
|
2022-06-01 18:47:00 +00:00
|
|
|
vidTime <= sponsor.segment[1]
|
2022-06-01 18:06:34 +00:00
|
|
|
) {
|
2022-06-01 06:13:16 +00:00
|
|
|
console.log("Skipping the sponsor");
|
2022-06-01 18:35:14 +00:00
|
|
|
vid.currentTime = sponsor.segment[1] + 1;
|
2022-06-01 06:13:16 +00:00
|
|
|
}
|
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;
|
|
|
|
}
|
2022-06-01 18:35:14 +00:00
|
|
|
.selfpromo {
|
|
|
|
color: yellow;
|
|
|
|
}
|
|
|
|
.exclusive_access {
|
|
|
|
color: orange;
|
|
|
|
}
|
|
|
|
.interaction {
|
|
|
|
color: blue;
|
|
|
|
}
|
|
|
|
.intro {
|
|
|
|
color: purple;
|
|
|
|
}
|
|
|
|
.outro {
|
|
|
|
color: purple;
|
|
|
|
}
|
|
|
|
.music_offtopic {
|
|
|
|
color: red;
|
|
|
|
}
|
|
|
|
.poi_highlight {
|
|
|
|
color: #ff00ff;
|
|
|
|
}
|
|
|
|
.filler {
|
|
|
|
color: blue;
|
|
|
|
}
|
2022-06-01 18:06:34 +00:00
|
|
|
</style>
|