HTML
Copy as MarkdownQuick start
Section titled “Quick start”-
Add the script line to your page. It defines the
<rupa-player>element.<script type="module" src="https://cdn.jsdelivr.net/npm/@rupamotion/player@0.1.0/dist/element.js"></script> -
Put
hero.rupaplay(export as Player file in Rupamotion) next to your page. -
Add the element where the animation goes:
<rupa-player src="hero.rupaplay"></rupa-player>
That’s it: the animation plays.
This demo loads a .rupaplay file: it plays once JavaScript runs.
Need control?
Section titled “Need control?”The element’s player is the player once the file is mounted, and rupaready says it is. Pause it from a button:
<rupa-player src="hero.rupaplay"></rupa-player><button id="pause">Pause</button><script type="module"> const el = document.querySelector("rupa-player"); document.querySelector("#pause").addEventListener("click", () => el.player?.pause());</script>See Control playback for play, seek, speed and states, and Events for
rupaready, rupaerror and the player’s own events.
One element for every framework
Section titled “One element for every framework”There is no wrapper per framework: React uses the /react entry, plain JavaScript uses mountFile from /file, and
every other framework uses the <rupa-player> custom element from /element. The export dialog of Rupamotion writes
these lines for you (export as Player file, then How to use). Serve the .rupaplay file from your site.
Lock the file
Section titled “Lock the file”To lock the page to the exact file, add integrity="sha256-..." (shown by the export dialog) and update it after every
re-export. See the file alone.