user1818924
user1818924

Reputation: 55

How to correctly create HTML5 audio and video with JavaScript

I checked out the w3c specification and it seems that in JavaScript we can create HTML5 audio in 2 ways, whereas for HTML5 video there's just one way:

Audio:

var audio = document.createElement('audio'); 

or

var audio = new Audio();

Video:

var video = document.createElement('video');

But is it true that for HTML5 video there is no equivalent constructor like new Video()?

//edit: seems like in March 2013 there was no equivalent..

Upvotes: 2

Views: 1154

Answers (1)

Keith Enlow
Keith Enlow

Reputation: 914

Sorry, as of now there is no other way to dynamically create a video in javascript other than using:

var video = document.createElement('video');

Upvotes: 1

Related Questions