The rupa-player element
Copy as MarkdownImport @rupamotion/player/element once (or load it from the CDN) to define <rupa-player>. The element loads a
.rupaplay file, writes its markup and CSS, and mounts a player.
<rupa-player src="/hero.rupaplay" markup="auto" integrity="sha256-..." cloak></rupa-player>Attributes
Section titled “Attributes”| Attribute | Meaning |
|---|---|
src |
The URL of the .rupaplay file. Changing it loads the new file. |
markup |
keep, replace or auto (the default). See your own markup. |
integrity |
The hash of the file, sha256-.... A file that does not match is refused with an integrity error. |
cloak |
Keeps the root hidden until the CSS is installed. |
Property
Section titled “Property”element.player is the Player, or null before the file is mounted or after a failed load.
Events
Section titled “Events”| Event | Bubbles | Detail |
|---|---|---|
rupaready |
yes | detail.player: the file is loaded and the player is mounted. |
rupaerror |
no | detail.error: the load failed and the element was left as it was. |
const el = document.querySelector("rupa-player");el.addEventListener("rupaready", (event) => event.detail.player.play());el.addEventListener("rupaerror", (event) => console.warn(event.detail.error.code));error.code is one of the error codes. The element destroys its player when it leaves the
page.