# The rupa-player element

Every attribute, property and event of the rupa-player custom element.

Import `@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.

```html
<rupa-player src="/hero.rupaplay" markup="auto" integrity="sha256-..." cloak></rupa-player>
```

## 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](/guides/your-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

`element.player` is the `Player`, or `null` before the file is mounted or after a failed load.

## 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. |

```js
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](/reference/error-codes/). The element destroys its player when it leaves the
page.
