Skip to content

Quick start

Copy as Markdown

Export your animation from Rupamotion as a Player file (a .rupaplay file) and put it next to your page. This page is complete: save it, serve it, and the animation plays.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Rupamotion player</title>
<script type="module" src="https://cdn.jsdelivr.net/npm/@rupamotion/player@0.1.0/dist/element.js"></script>
</head>
<body>
<rupa-player src="/hero.rupaplay" cloak></rupa-player>
</body>
</html>

The element loads the file, writes its markup and CSS, and mounts the player (element.player). cloak keeps the root hidden until the CSS is installed. That is it: the animation plays. This one is a .rupaplay file loaded and played by the player of this version:

This demo loads a .rupaplay file: it plays once JavaScript runs.

The element’s player is the player once the file is mounted. rupaready says it is mounted, rupaerror says the load failed. Add a script after the element:

<script type="module">
const el = document.querySelector("rupa-player");
el.addEventListener("rupaready", () => el.player.play());
el.addEventListener("rupaerror", (event) => console.warn(event.detail.error.code));
</script>

See Control playback for play, pause, seek, speed and states, and Events for what a player tells you.