I'm testing javascript on a smart TV,
I try to get an object video to canvas. With html5 video tag it works in my browser, but not my smart TV.
But when I try with an object player, I have this error message :
Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(HTMLImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap)'
after multiple test with (id, object id,object src..) the result is same, i don't know how i can get an Object video to a canvas.
here's a simple html test:
<canvas id="test" width="300" height="300"></canvas>
<div id="test" style="left: 0%; top: 0%; width: 25%; height: 25%; position: fixed;">
<object type="application/avplayer" style="width: 480px; height: 270px;"></object>
</div>
and the js:
const canvas = document.querySelector("canvas");
const ctx = canvas.getContext("2d");
const video = document.getElementsByTagName('object');
//const video = document.getElementsById('idVideo');
ctx.drawImage(video, 0, 0, canvas.width, canvas.height)
Here's an example of my goal but i can't use video tag : http://jsfiddle.net/on1kh4o0/
Any idea or hack to get the same result with an object?
videoelement instead ofobject. See stackoverflow.com/questions/33834724/draw-video-on-canvas-html5drawImageon aHTMLObjectElementtype, which the error suggests; won't work.document.getElementsByTagName()returns an array. So you should usevideo[0]and notvideo. Unless you have multiple objects in your elements, in which case you have to use the correct index number instead of 0.CanvasRenderingContext2D.drawImage()has a list of types it allows as a validCanvasImageSourcetype.HTMLObjectElementis not one of them..ogvsource. Does your TV support that format?