Back to api.video Glossary
Loop
What is the video loop attribute in HTML5?
Loop is an attribute used in the HTML5 video tag. When the loop attribute is added to the video, it tells the player to restart the video when it completes, causing a loop in the video. When the loop tag is added to a video, the video will loop indefinitely, there is no way to define just one or two loops of the video.
When combined with muted and autoplay the effect is similar to that of an animated GIF - with the advantage that typically video files are smaller than an animated GIF.
Loop with api.video
Video:
For a single video, you can add #loop to the end of the player url, and the video will loop:
Or you can add the loop parameter when you use the player SDK:
player.loadConfig({
id: "<VIDEO_ID>",
hideTitle: true,
loop: true,
});
Player:
If you have many videos that you'd like to have loop, you can create a video player that defaults to looping videos, and assign the videos you wish to loop to that player by initializing forceLoop
to true:
curl --request POST \
--url https://ws.api.video/players \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '
{
"enableApi": true,
"enableControls": true,
"forceAutoplay": false,
"hideTitle": false,
"forceLoop": true
}
'
Learn more about our video player, fully customizable, with prefect playback quality.