mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 10:31:20 -08:00
refactor(auto-thumbnail): [PKG-AUTO-THUMB-03] type internal extraction contracts
This commit is contained in:
1 parent
00e81309ca
commit
6c989deccd
20 files changed
+3968
-48
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import type { ExtractionJob } from './types'
|
||||
|
||||
export default function createVideo(job: ExtractionJob) {
|
||||
const video = document.createElement('video')
|
||||
job.own(() => video.remove())
|
||||
job.own(() => video.load())
|
||||
job.own(() => video.removeAttribute('src'))
|
||||
job.own(() => video.pause())
|
||||
for (const property of ['onloadedmetadata', 'onloadeddata', 'onseeked', 'onerror'] as const)
|
||||
job.own(() => { video[property] = null })
|
||||
if (!job.active())
|
||||
return video
|
||||
video.crossOrigin = 'anonymous'
|
||||
video.muted = true
|
||||
video.playsInline = true
|
||||
video.tabIndex = -1
|
||||
video.setAttribute('aria-hidden', 'true')
|
||||
// WebKit needs a rendered box; display:none and a 1px box lose decoded pixels.
|
||||
video.style.cssText = 'position:fixed;left:0;top:0;visibility:hidden;pointer-events:none;display:block;width:auto;height:auto;max-width:none;max-height:none'
|
||||
document.documentElement.appendChild(video)
|
||||
if (!job.active())
|
||||
video.remove()
|
||||
return video
|
||||
}
|
||||
Reference in new issue
Block a user