0.0.22 • Published 9 months ago

@avaturn-live/web-sdk v0.0.22

Weekly downloads
-
License
-
Repository
github
Last release
9 months ago

Avaturn Live Integration Example

This example demonstrates how to integrate and use the AvaturnHead from the @avaturn-live/web-sdk package to display an avatar's video stream on a web page.

Prerequisites

Before running the code, make sure you have a valid session token for Avaturn:

Installation

npm install @avaturn-live/web-sdk

Usage

  1. Import the AvaturnHead class from the @avaturn-live/web-sdk package.

    import { AvaturnHead } from "@avaturn-live/web-sdk";
  2. Initialize the AvaturnHead instance with your session token.

    const avatar = new AvaturnHead({ sessionToken: "<YOUR_SESSION_TOKEN>" });
  3. Once the avatar is initialized, get a reference to the HTML video element where you want to display the avatar's video stream.

    avatar.init().then(() => {
      const videoRef: HTMLVideoElement = document.querySelector("#video")!;
      videoRef.srcObject = avatar.mediaStream;
      videoRef.play();
    });

HTML Structure

Ensure you have an HTML structure with a video element that has an id of video:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Avaturn Head Example</title>
  </head>
  <body>
    <video id="video" autoplay></video>

    <!-- Include your bundled JavaScript here -->
  </body>
</html>
0.0.20

9 months ago

0.0.21

9 months ago

0.0.22

9 months ago

0.0.17

10 months ago

0.0.16

10 months ago

0.0.15

10 months ago

0.0.14

10 months ago

0.0.12

10 months ago

0.0.11

10 months ago

0.0.10

10 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

10 months ago