Have you tried doing the HTML5 loop tag?
<video id="yourID" autoplay="autoplay" loop="loop">
<!--source code here-->
</video>
EDIT: To get this to work from JavaScript do the following.
var video = document.createElement('video'); //To create the video element.
video.loop = true;