Skip to content

Commit

Permalink
fix: remove debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
qq15725 committed Feb 22, 2023
1 parent 2bb1c3f commit 88232a2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/clone-video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export async function cloneVideo<T extends HTMLVideoElement>(
return createImage(video.poster, video.ownerDocument)
}

video.currentTime = 3

const clone = video.cloneNode(false) as T
clone.crossOrigin = 'anonymous'
if (video.currentSrc && video.currentSrc !== video.src) {
Expand All @@ -28,6 +26,9 @@ export async function cloneVideo<T extends HTMLVideoElement>(
onError: () => canPlay = false,
})
if (!canPlay) {
if (video.poster) {
return createImage(video.poster, video.ownerDocument)
}
return clone
}
clone.currentTime = video.currentTime
Expand All @@ -42,6 +43,9 @@ export async function cloneVideo<T extends HTMLVideoElement>(
if (ctx) ctx.drawImage(clone, 0, 0, canvas.width, canvas.height)
} catch (error) {
consoleWarn('Failed to clone video', error)
if (video.poster) {
return createImage(video.poster, video.ownerDocument)
}
return clone
}
return cloneCanvas(canvas)
Expand Down

0 comments on commit 88232a2

Please sign in to comment.