To get started with the Banuba WebAR you need to:
- Create a JS file which will contain the exemplar of
BanubaSDK. This object is an API for web assembly native code.
BanubaSDK.webcamHandler.loadUserMedia()method. This method links the user web camera stream with HTML5 video element.
BanubaSDK.startPlayback()to start web camera playback.
To fetch the effect you should call
BanubaSDK.fetchEffect() and set the first argument exemplar of
BanubaSDKLoadResourceHandler class. The constructor of
string argument which is the name of the effect.
You can set 4 event listeners to the exemplar of
- finish listener
- progress listener
- error listener
- abort listener.
Finish, error and abort receive
XMLHttpRequest objects. Progress listener receives
XMLHttpRequest objects and data size of a
After fetching the effect you can play it by calling
BanubaSDK.loadEffect() receives a
string argument, which should be the name of some of the fetched effects.
BanubaSDKManager you can set 2 event listeners:
- effects metadata loading event listener
- fps updating event listener.
To set effects metadata loading event listener, call
BanubaSDK.setStatusListener() method. This method gets
callback, which receives an object with loading status data. The object has 3 props:
boolean isLoaded, and 2
numerics currentProgress and dataSize.
To set fps updating event listener, call
BanubaSDK.setFPSUpdateListener()method. This method gets
callback, which receives a
numeric argument: the current FPS.
The constructor of
BanubaSDKManager receives 1 required argument:
HTML5 canvas, and 2 optional arguments: effects metadata loading event listener and FPS update listener mentioned above.
BanubaSDKManager includes the follwing methods that control the effects' playback:
BanubaSDKManager.setVolume()— receives a
numericargument in between [0;1] which is the volume level.
BanubaSDKManager.pause()- pauses video playback.
BanubaSDKManager.play()— unpauses playback and is commonly called after
BanubaSDK.updateEffectProps()— updates the effect properties and receives a
stringargument which should be the effect's property name.
ImageDataobject which represents the underlying pixel data of an area of a
canvas HTML5element and sends the native code to WebAssembly. Commonly called in playback loop in