Options
All
  • Public
  • Public/Protected
  • All
Menu

High level API over native SDK

Hierarchy

  • EventTarget
    • Player

Implements

  • EventTarget

Index

Events

Static Readonly EFFECT_ACTIVATED_EVENT

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

Static Readonly FRAME_DATA_EVENT

FRAME_DATA_EVENT: "framedata" = "framedata"

Triggered when a new {@link BanubaSDK.FrameData} is ready

example
player.addEventListener("framedata", (event) => {
  const frameData = event.detail
  const face = frameData
    .getFrxRecognitionResult()
    .getFaces()
    .get(0)

  if (!face.hasFace()) return

  const landmarks = face.getLandmarks()

  for (let i = 0; i < landmarks.size(); ++i)
    console.log(landmarks.get(i))
})

Static Readonly FRAME_PROCESSED_EVENT

FRAME_PROCESSED_EVENT: "frameprocessed" = "frameprocessed"

Triggered when a frame is processed by underlying neural networks

Static Readonly FRAME_RECEIVED_EVENT

FRAME_RECEIVED_EVENT: "framereceived" = "framereceived"

Triggered when a frame is received from the specified Input

Static Readonly FRAME_RENDERED_EVENT

FRAME_RENDERED_EVENT: "framerendered" = "framerendered"

Triggered when a frame is rendered

Accessors

isPlaying

  • get isPlaying(): boolean
  • Returns boolean

Methods

addEventListener

  • addEventListener<PlayerEvent>(type: PlayerEvent, listener: (evt: CustomEvent<PlayerEventMap[PlayerEvent]>) => any, options?: boolean | AddEventListenerOptions): void
  • addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void
  • Type parameters

    Parameters

    • type: PlayerEvent
    • listener: (evt: CustomEvent<PlayerEventMap[PlayerEvent]>) => any
    • Optional options: boolean | AddEventListenerOptions

    Returns void

  • Parameters

    • type: string
    • listener: EventListenerOrEventListenerObject
    • Optional options: boolean | AddEventListenerOptions

    Returns void

applyEffect

  • applyEffect(effect: Effect): Promise<Effect>
  • Applies an effect to input

    example
    const octopus = new Effect("effects/octopus.zip")
    
    player.applyEffect(octopus)
    

    Parameters

    Returns Promise<Effect>

callJsMethod

  • callJsMethod(methodName: string, methodJSONParams?: string): void
  • Evaluates JavaScript in context of applied effect

    Parameters

    • methodName: string
    • methodJSONParams: string = ""

    Returns void

clearEffect

  • clearEffect(): Promise<void>
  • Clears effect applied to input

    Returns Promise<void>

pause

  • pause(): void
  • Stops input processing

    Returns void

play

  • play(): Promise<void>
  • Starts input processing

    Returns Promise<void>

removeEventListener

  • removeEventListener<PlayerEvent>(type: PlayerEvent, listener: (evt: CustomEvent<PlayerEventMap[PlayerEvent]>) => any, options?: boolean | EventListenerOptions): void
  • removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void
  • Type parameters

    Parameters

    • type: PlayerEvent
    • listener: (evt: CustomEvent<PlayerEventMap[PlayerEvent]>) => any
    • Optional options: boolean | EventListenerOptions

    Returns void

  • Parameters

    • type: string
    • listener: EventListenerOrEventListenerObject
    • Optional options: boolean | EventListenerOptions

    Returns void

setVolume

  • setVolume(level: number): void
  • Sets effect volume from 0 to 1

    Parameters

    • level: number

    Returns void

use

  • Uses the input as frames source

    example
    player.use(new Webcam())
    

    Parameters

    Returns void

Static create