I am trying to create a new HTML5 video elemnt entirely throught JS. So I try to do it the same way I create a new image, like: obj = new Image()
I write obj = new HTMLVideoElement()
. However this doesn't work. I get the runtime error: Object doesn't support this action.
What is wrong? Thanks.
Use the <video> tag for inserting videos in HTML The <video> tag is added in HTML5 along with its sibling, <audio>. Before the release of HTML5, a video could only be played in a browser with a plug-in (like a flash). The HTML5 <video> element specifies a standard way to embed a video in a web page.
HTML allows playing video in the web browser by using <video> tag. To embed the video in the webpage, we use src element for mentioning the file address and width and height attributes are used to define its size. Example: In this example, we are using <video> tag to add video into the web page.
The HTML <video> element is used to embed video in web documents. It may contain one or more video sources, represented using the src attribute or the source element. The <video> element is supported by all modern browsers.
The Image
class is a special case.
The standard way to create any arbitrary HTML element is this:
var obj = document.createElement('video');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With