RupaPlayerElement
Copy as Markdown<rupa-player>: a .rupaplay file mounted into the element, defined by importing @rupamotion/player/element (or
loading its CDN script). The element is the player’s root container: the file’s markup is written into it.
Attributes (each change loads again; the element loads while it is in the page and has a src):
src: the file’s URL.markup:keep,replaceorauto(the default: an empty element gets the file’s markup), asMountFileOptions.integrity: the file’ssha256-<base64>hash, checked before it is read.cloak: present, the element is hidden until the file’s CSS is installed (or the load failed).
Events:
rupaready(bubbles): the file is mounted;event.detail.playeris thePlayer.rupaerror(does not bubble): the load failed and the element was left as it was;event.detail.erroris theFileError,event.detail.srcthesrcof that load (an older load replaced while in flight sends it too).
Taken out of the page, the element destroys its player; moved within the same document or shadow root, it keeps it.
Example
Section titled “Example”<script type="module" src="https://cdn.jsdelivr.net/npm/@rupamotion/player/dist/element.js"></script><rupa-player src="/hero.rupaplay" cloak></rupa-player><script type="module"> const element = document.querySelector("rupa-player"); element.addEventListener("rupaready", (event) => event.detail.player.play("intro")); element.addEventListener("rupaerror", (event) => console.warn(event.detail.error.code));</script>Extends
Section titled “Extends”HTMLElement
Properties
Section titled “Properties”player
Section titled “player”
readonlyplayer:Player<string> |null
The player once the file is mounted; null before, after a failure, a change of the load or a disconnect.