(video: HTMLVideoElement)
| 20 | } |
| 21 | |
| 22 | export const captureFrame = (video: HTMLVideoElement): Promise<string> => { |
| 23 | return new Promise(function (resolve) { |
| 24 | const canvas = document.createElement("canvas") as HTMLCanvasElement |
| 25 | canvas.width = video.videoWidth |
| 26 | canvas.height = video.videoHeight |
| 27 | canvas.getContext("2d")!.drawImage(video, 0, 0, canvas.width, canvas.height) |
| 28 | URL.revokeObjectURL(video.src) |
| 29 | |
| 30 | const data = canvas.toDataURL() |
| 31 | |
| 32 | fetch(data) |
| 33 | .then((res) => { |
| 34 | return res.blob() |
| 35 | }) |
| 36 | .then((blob) => { |
| 37 | const url = URL.createObjectURL(blob) |
| 38 | resolve(url) |
| 39 | }) |
| 40 | }) |
| 41 | } |
| 42 | |
| 43 | export const captureDuration = (video: HTMLVideoElement) => { |
| 44 | return new Promise((resolve) => { |
no outgoing calls
no test coverage detected