I'm trying to load and play a HTML5 video onClick event. But i'm not able to accomplish this :-/
Here's my HTML5:
<div id="divVideo">
<video id="video" controls width="560">
<source id="mp4" type="video/mp4" />
</video>
</div>
<div onclick="loadVideo('Muse-Animals.mp4');">play</div>
Here's my JS:
function loadVideo(id)
{
var video = document.getElementById('video');
var mp4 = document.getElementById('mp4');
mp4.src = "vidz/" + id;
video.load();
video.play();
}
I checked the element and it does update the video tag properties, but doesn't load or play the video.
What am i doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…