The file alone
Copy as Markdown<rupa-player src="/hero.rupaplay" integrity="sha256-..." cloak></rupa-player><script type="module" src="https://cdn.jsdelivr.net/npm/@rupamotion/player@0.1.0/dist/element.js"></script>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. integrity locks the page to the exact file: the player refuses a file that was
changed, and you update the value after every re-export.
This demo loads a .rupaplay file: it plays once JavaScript runs.
import { mountFile } from "@rupamotion/player/file";
const { player } = await mountFile(document.querySelector("#card-flip"), "/card-flip.rupaplay", { markup: "replace" });
player.play("flip"); The element reports on itself with two events:
const el = document.querySelector("rupa-player");el.addEventListener("rupaready", () => el.player.play()); // the file is loaded and the player mountedel.addEventListener("rupaerror", (event) => console.warn(event.detail.error.code)); // a failed loadmountFile sends the same rupaerror on its root. The error event of a Player exists only after a successful
mount. See the element reference for every attribute.