I'm trying to change the source and the poster of a html5 video onClick().
This is what I have. But the chage of the URL doesn't work?!
JS:
- Code: Select all
function loadAnotherVideo(oggURL, posterURL) {
var video = document.getElementsByTagName('video')[0];
var sources = video.getElementsByTagName('source');
video.poster = posterURL;
sources[0].src = oggURL;
}
HTML
- Code: Select all
<video width="622" height="366" controls poster="bla.jpg" >
<source src="big_buck_bunny_480p_stereo.ogg" type='video/ogg; codecs="theora, vorbis"'>
</video>
<a href="#" onclick="loadAnotherVideo('video2.ogv', 'bla.jpg')">Video 1</a>
All files are in the directory.
Any Ideas?
Thank You!