From e13a6d684b88a2250f807d4c03e96a0719791deb Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Thu, 27 May 2021 18:38:30 -0400 Subject: [PATCH] add bufferToVideo --- CHANGELOG.md | 11 ++++++++--- src/dom/bufferToVideo.ts | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 src/dom/bufferToVideo.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index dc23ee1..7188ff2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,11 +9,16 @@ Repository: **** ## Changelog +### **HEAD -> master** 2021/05/27 mandic00@live.com + + +### **origin/master** 2021/05/27 hello@bettysteger.com + +- force typescript 4.2 due to typedoc incompatibility with ts 4.3 + ### **1.2.5** 2021/05/27 mandic00@live.com - -### **origin/master** 2021/05/27 admin@bettysteger.com - +- add buffertovideo and fetchvideo (#54) ### **1.2.4** 2021/05/18 mandic00@live.com diff --git a/src/dom/bufferToVideo.ts b/src/dom/bufferToVideo.ts new file mode 100644 index 0000000..07c4034 --- /dev/null +++ b/src/dom/bufferToVideo.ts @@ -0,0 +1,16 @@ +import { env } from '../env/index'; + +export function bufferToVideo(buf: Blob): Promise { + return new Promise((resolve, reject) => { + if (!(buf instanceof Blob)) reject(new Error('bufferToVideo - expected buf to be of type: Blob')); + + const video = env.getEnv().createVideoElement(); + video.oncanplay = () => resolve(video); + video.onerror = reject; + // video.type = buf.type; + video.playsInline = true; + video.autoplay = true; + video.muted = true; + video.src = URL.createObjectURL(buf); + }); +}