Loop a video
Looping a video is possible using our JavaScript API.
The following is a simple example of the code needed to achieve this:
HTML Code
<video class="sublime" poster="posterframe.jpg" width="640" height="360" preload="none"> <source src="video.mp4" /> <source src="video.webm" /> </video>
Note: This is a classic <video>, nothing special here.
JavaScript Code
Put this code in a <script> element just before the </body> tag, or in an external file.
sublimevideo.ready(function() { sublimevideo.onEnd(function(sv) { sublimevideo.play(sv.element); }); });
Note: If you don’t want to loop all of the videos in your page, you can add conditions before calling sublimevideo.play (for example adding an id to your <video> element and then perform a check on sv.element.id).
Demo
You can see this feature in action on this page.