Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Javascript: embed video or video player in HTML

21.05.2018 (👁4797)


This code will embed a .mp4 video into an HTML web page at runtime.

HTML5, javascript

//--< add Video-Player >--

var divEditor = document.getElementById("ctlEditor_HTML");

 

 

//*show uploaded Image in div-Results

var br = document.createElement("br");

divEditor.insertBefore(br, divEditor.childNodes[0]);

 

//< create image >

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

video.src = "/User_Files/Notes/Videos/" + item + ".mp4"

video.setAttribute("width","640");

video.setAttribute("height", "480");

video.setAttribute("controls","");

video.setAttribute("autoplay","");

video.style.width = "100%";

video.style.maxWidth = "100%";

video.style.height = "auto";

video.style.display = "block";

video.style.borderWidth = "2px";

video.style.borderColor = "black";

video.style.borderStyle = "solid";

//</ create image >

 

//*at position 0

divEditor.insertBefore(video, divEditor.childNodes[0]);

//--</ add Video-Player >--

 

<video src="/User_Files/Notes/Videos/Video_338_0.mp4" width="640" height="480" controls="" autoplay="" style="width: 100%; max-width: 100%; height: auto; display: block; border-width: 2px; border-color: black; border-style: solid;"></video>