Banuba WebAR JavaScript API Reference
    Preparing search index...

    Class Player

    High level API over compiled Banuba SDK

    Index

    Accessors

    • get isPlaying(): boolean

      Returns boolean

    Methods

    • Type Parameters

      Parameters

      • event: E
      • listener: EventListener<PlayerEventMap[E]>
      • Optionaloptions: boolean | AddEventListenerOptions

      Returns void

    • Adds additional modules like face_tracker, background and many others to the Player and makes them available for effects

      Parameters

      Returns Promise<void>

      const frx = new Module("/path/to/face_tracker.zip")

      await player.addModule(frx)
    • Applies an effect to input

      Parameters

      Returns Promise<BanubaSDK.Effect>

      const octopus = new Effect("/path/to/Octopus.zip")

      await player.applyEffect(octopus)
    • Evaluates JavaScript in context of applied effect.

      Parameters

      • methodName: string
      • methodJSONParams: string = ""

      Returns Promise<void>

      Use Effect.evalJs instead.

    • Clears effect applied to input

      Returns Promise<void>

    • Destroys the Player instance, clears all the resources used

      Returns Promise<void>

    • Stops input processing

      Returns void

    • Starts input processing.

      Accepts playback options object with optional fps and pauseOnEmpty keys.

      Parameters

      Returns void

      /// The `fps` playback option persists between invocations:

      const desiredFps = 25

      player.play({ fps: desiredFps })
      player.play() // same as passing `{ fps: desiredFps }`
      /// The `pauseOnEmpty` playback option resets to `true` between invocations:

      await player.use(new Image(file))
      player.applyEffect(new Effect("path/to/Spider.zip")) // an effect with animations

      player.play({ pauseOnEmpty: false })
      player.play() // same as passing `{ pauseOnEmpty: true }`
    • Type Parameters

      Parameters

      • event: E
      • listener: EventListener<PlayerEventMap[E]>
      • Optionaloptions: boolean | EventListenerOptions

      Returns void

    • Sets effect volume from 0 to 1

      Parameters

      • level: number

      Returns void

    • Uses the input as frames source

      Parameters

      Returns void

      player.use(new Webcam())
      

    Events

    EFFECT_ACTIVATED_EVENT: "effectactivated"

    Triggered when an Effect is activated

    Note: By default the Player starts with an "empty" Effect applied which does nothing but rendering

    FRAME_DATA_EVENT: "framedata"

    Triggered when a new FrameData is ready

    player.addEventListener("framedata", ({ detail: frameData }) => {
    const hasFace = frameData.get("frxRecognitionResult.faces.0.hasFace")
    if (!hasFace) return

    const landmarks = frameData.get("frxRecognitionResult.faces.0.landmarks")
    console.log(landmarks)
    })
    FRAME_PROCESSED_EVENT: "frameprocessed"

    Triggered when a frame is processed by underlying neural networks

    FRAME_RECEIVED_EVENT: "framereceived"

    Triggered when a frame is received from the specified Input

    FRAME_RENDERED_EVENT: "framerendered"

    Triggered when a frame is rendered