Skip to content
  1. Install the player.

    Terminal window
    npm i @rupamotion/player
  2. Put hero.rupaplay (export as Player file in Rupamotion) in the public folder or the assets of your project.

  3. CUSTOM_ELEMENTS_SCHEMA lets the template use rupa-player. Add it to the schemas of the component that uses the element (the component in step 4 has it).

  4. Import the element and use it in the template:

    import { Component, CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
    import "@rupamotion/player/element";
    @Component({
    selector: "app-hero",
    schemas: [CUSTOM_ELEMENTS_SCHEMA],
    template: `<rupa-player src="/hero.rupaplay"></rupa-player>`,
    })
    export class HeroComponent {}

That’s it: the animation plays.

This demo loads a .rupaplay file: it plays once JavaScript runs.

Take the element with @ViewChild. Its player is the player once the file is mounted (null before):

import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, ViewChild } from "@angular/core";
import "@rupamotion/player/element";
import type { RupaPlayerElement } from "@rupamotion/player/element";
@Component({
selector: "app-hero",
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<rupa-player #hero src="/hero.rupaplay"></rupa-player>
<button (click)="pause()">Pause</button>
`,
})
export class HeroComponent {
@ViewChild("hero") hero?: ElementRef<RupaPlayerElement>;
pause() {
this.hero?.nativeElement.player?.pause();
}
}

See Control playback and Events.