High level API over compiled Banuba SDK

Hierarchy

Accessors

  • get isPlaying(): boolean
  • Returns boolean

Methods

  • Type Parameters

    Parameters

    • event: E
    • listener: EventListener<PlayerEventMap[E]>
    • Optional options: 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>

    Example

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

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

    Parameters

    Returns Promise<BanubaSDK.Effect>

    Example

    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>

    Deprecated

    Use 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

    Example

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

    const desiredFps = 25

    player.play({ fps: desiredFps })
    player.play() // same as passing `{ fps: desiredFps }`

    Example

    /// 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]>
    • Optional options: 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

    Example

    player.use(new Webcam())
    

Events

EFFECT_ACTIVATED_EVENT: "effectactivated" = "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" = "framedata"

Triggered when a new FrameData is ready

Example

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" = "frameprocessed"

Triggered when a frame is processed by underlying neural networks

FRAME_RECEIVED_EVENT: "framereceived" = "framereceived"

Triggered when a frame is received from the specified Input

FRAME_RENDERED_EVENT: "framerendered" = "framerendered"

Triggered when a frame is rendered