RupaPlayer
Copy as Markdown
constRupaPlayer: (props) =>ReactElement
A div the .rupaplay file src is mounted into, after the render (on a server it renders the div alone). Its
ref is given the Player once the file is mounted, null before and after (player.root is the div, or the
element of the file’s root class inside it). Unmounting destroys the player.
Parameters
Section titled “Parameters”RupaPlayerProps & RefAttributes<Player<string>>
The file’s props and the div’s (see RupaPlayerProps); ref receives the Player.
Returns
Section titled “Returns”ReactElement
The div.
Example
Section titled “Example”import { useRef } from "react";import type { Player } from "@rupamotion/player";import { RupaPlayer } from "@rupamotion/player/react";
export function Hero() { const player = useRef<Player>(null); return ( <RupaPlayer ref={player} src="/hero.rupaplay" markup="auto" cloak onReady={(ready) => ready.play("intro")} onError={(error) => console.warn(error.code)} /> );}