|
|
@ -5,6 +5,7 @@ import { playerStatus } from "@/stores/player/slices/source"; |
|
|
|
import { ThumbnailImage } from "@/stores/player/slices/thumbnails"; |
|
|
|
import { ThumbnailImage } from "@/stores/player/slices/thumbnails"; |
|
|
|
import { usePlayerStore } from "@/stores/player/store"; |
|
|
|
import { usePlayerStore } from "@/stores/player/store"; |
|
|
|
import { LoadableSource, selectQuality } from "@/stores/player/utils/qualities"; |
|
|
|
import { LoadableSource, selectQuality } from "@/stores/player/utils/qualities"; |
|
|
|
|
|
|
|
import { isSafari } from "@/utils/detectFeatures"; |
|
|
|
|
|
|
|
|
|
|
|
function makeQueue(layers: number): number[] { |
|
|
|
function makeQueue(layers: number): number[] { |
|
|
|
const output = [0, 1]; |
|
|
|
const output = [0, 1]; |
|
|
@ -39,11 +40,9 @@ class ThumnbnailWorker { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
start(source: LoadableSource) { |
|
|
|
start(source: LoadableSource) { |
|
|
|
|
|
|
|
if (isSafari) return false; |
|
|
|
const el = document.createElement("video"); |
|
|
|
const el = document.createElement("video"); |
|
|
|
el.setAttribute("muted", "true"); |
|
|
|
el.setAttribute("muted", "true"); |
|
|
|
// ! Remove before merging
|
|
|
|
|
|
|
|
el.setAttribute("controls", "true"); |
|
|
|
|
|
|
|
el.setAttribute("playsinline", "true"); |
|
|
|
|
|
|
|
const canvas = document.createElement("canvas"); |
|
|
|
const canvas = document.createElement("canvas"); |
|
|
|
this.hls = new Hls(); |
|
|
|
this.hls = new Hls(); |
|
|
|
if (source.type === "mp4") { |
|
|
|
if (source.type === "mp4") { |
|
|
@ -69,8 +68,6 @@ class ThumnbnailWorker { |
|
|
|
|
|
|
|
|
|
|
|
private async initVideo() { |
|
|
|
private async initVideo() { |
|
|
|
if (!this.videoEl || !this.canvasEl) return; |
|
|
|
if (!this.videoEl || !this.canvasEl) return; |
|
|
|
// ! Remove before merging
|
|
|
|
|
|
|
|
document.body.appendChild(this.videoEl); |
|
|
|
|
|
|
|
await new Promise((resolve, reject) => { |
|
|
|
await new Promise((resolve, reject) => { |
|
|
|
this.videoEl?.addEventListener("loadedmetadata", resolve); |
|
|
|
this.videoEl?.addEventListener("loadedmetadata", resolve); |
|
|
|
this.videoEl?.addEventListener("error", reject); |
|
|
|
this.videoEl?.addEventListener("error", reject); |
|
|
@ -103,15 +100,6 @@ class ThumnbnailWorker { |
|
|
|
); |
|
|
|
); |
|
|
|
const imgUrl = this.canvasEl.toDataURL(); |
|
|
|
const imgUrl = this.canvasEl.toDataURL(); |
|
|
|
|
|
|
|
|
|
|
|
// ! Remove before merging
|
|
|
|
|
|
|
|
const img = new Image(); |
|
|
|
|
|
|
|
img.src = imgUrl; |
|
|
|
|
|
|
|
img.style.border = "1px solid yellow"; |
|
|
|
|
|
|
|
document.body.appendChild(img); |
|
|
|
|
|
|
|
const p = document.createElement("p"); |
|
|
|
|
|
|
|
p.innerText = `${at}`; |
|
|
|
|
|
|
|
document.body.appendChild(p); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.interrupted) return; |
|
|
|
if (this.interrupted) return; |
|
|
|
if (imgUrl === "data:," || !imgUrl) return; // failed image rendering
|
|
|
|
if (imgUrl === "data:," || !imgUrl) return; // failed image rendering
|
|
|
|
|
|
|
|
|
|
|
@ -163,6 +151,7 @@ export function ThumbnailScraper() { |
|
|
|
workerRef.current = ins; |
|
|
|
workerRef.current = ins; |
|
|
|
ins.start(inputStream.stream); |
|
|
|
ins.start(inputStream.stream); |
|
|
|
}, [source, addImage, resetImages, status]); |
|
|
|
}, [source, addImage, resetImages, status]); |
|
|
|
|
|
|
|
|
|
|
|
const startRef = useRef(start); |
|
|
|
const startRef = useRef(start); |
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
startRef.current = start; |
|
|
|
startRef.current = start; |
|
|
|