Package com.banuba.sdk.player
Class Player
java.lang.Object
com.banuba.sdk.player.VerifyCloseable
com.banuba.sdk.player.Player
- All Implemented Interfaces:
Closeable,AutoCloseable
Class manages the lifecycle of the EffectPlayer and is responsible for drawing FrameData
that comes from Input, then processing frame and sending it to Output (or Outputs).
Owns and manages the render thread.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfaceRendering status callbackstatic enumRendering modesstatic class -
Field Summary
Fields inherited from class com.banuba.sdk.player.VerifyCloseable
mIsClosed, mTag -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a new one output to output list.voidclose()Destroy the Player.voidEvaluate the `script` in effectcom.banuba.sdk.effect_player.EffectPlayerGet an instance of the EffectPlayercom.banuba.sdk.effect_player.EffectSynchronous loading of an effect by namecom.banuba.sdk.effect_player.EffectLoad effect asynchronously by namecom.banuba.sdk.effect_player.EffectloadAsync(String effect, Player.IEffectActivatedCallback effectActivated) Load effect asynchronously by namevoidpause()Pause the playback of the effect.voidplay()Resume the playback of the effect.com.banuba.sdk.effect_player.ReloadResultReload config for current effectvoidremoveOutput(IOutput output) Remove one output from output list.longrender()Draw and present rendered result synchronously, can be used only in `manual` rendering mode.voidsetEffectVolume(float volume) Set effect audio volume.voidsetRenderMode(Player.RenderMode newRenderMode) Set rendering mode to another.voidsetRenderStatusCallback(Player.IRenderStatusCallback renderStatusCallback) Sets the rendering callbackvoidstop()Stop the playback of the effect, detach inputs/outputs and destroy RenderTarget.voidUse new InputvoidUse single Input and single Output.voidUse single Input and multiple Outputs.voidUse single new Output and remove oldvoidUse new Output's and remove oldMethods inherited from class com.banuba.sdk.player.VerifyCloseable
finalize
-
Constructor Details
-
Player
public Player()Create a new instance of the Player, with frame rate 30 FPS -
Player
public Player(int fps) Create a new instance of the Player, with given FPS- Parameters:
fps- required frames per second
-
Player
public Player(int fps, boolean useThread) Create a new instance of the Player, with given params- Parameters:
fps- required frames per seconduseThread- use RenderThread to isolate GPU context
-
-
Method Details
-
setRenderMode
Set rendering mode to another. By default, the render mode is set to LOOP.- Parameters:
newRenderMode- new rendering mode
-
setRenderStatusCallback
Sets the rendering callback- Parameters:
renderStatusCallback- the rendering callback or null
-
play
public void play()Resume the playback of the effect. For example this method must be call in overloaded 'AppCompatActivity.onResume()' method. -
pause
public void pause()Pause the playback of the effect. For example this method must be call in overloaded 'AppCompatActivity.onPause()' method. -
stop
public void stop()Stop the playback of the effect, detach inputs/outputs and destroy RenderTarget. Call `play` to recreate `RenderTarget` -
close
public void close()Destroy the Player. Must be call when the Player should be destroyed. Otherwise it might be a memory leak.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classVerifyCloseable
-
getEffectPlayer
@NonNull public com.banuba.sdk.effect_player.EffectPlayer getEffectPlayer()Get an instance of the EffectPlayer -
setEffectVolume
public void setEffectVolume(float volume) Set effect audio volume.- Parameters:
volume- A value in range `[0, 1]`, where `1` means maximum volume.
-
use
Use new Input- Parameters:
input- frames will be receive from it
-
use
Use single new Output and remove old- Parameters:
output- processed frames will be push to it
-
use
Use new Output's and remove old- Parameters:
outputs- processed frames will be push to these outputs
-
use
Use single Input and single Output.- Parameters:
input- frames will be receive from itoutput- processed frames will be push to it
-
use
Use single Input and multiple Outputs.- Parameters:
input- frames will be receive from itoutputs- processed frames will be push to these outputs
-
addOutput
Add a new one output to output list.- Parameters:
output- processed frames will be push to it
-
removeOutput
Remove one output from output list.- Parameters:
output- delete this output from outputs
-
loadAsync
@Nullable public com.banuba.sdk.effect_player.Effect loadAsync(String effect, Player.IEffectActivatedCallback effectActivated) Load effect asynchronously by name- Parameters:
effect- path to the effect or effect nameeffectActivated- effect activation listener
-
loadAsync
Load effect asynchronously by name- Parameters:
effect- path to the effect or effect name
-
load
Synchronous loading of an effect by name- Parameters:
effect- path to the effect or effect name
-
reload
Reload config for current effect- Parameters:
config- effect config JSONsync- wait until effect is reloaded and activated
-
evalJs
public void evalJs(@NonNull String script, @Nullable com.banuba.sdk.effect_player.JsCallback resultCallback) Evaluate the `script` in effect- Parameters:
script- JS string to executeresultCallback- Callback for result, will be called in render thread.
-
render
public long render()Draw and present rendered result synchronously, can be used only in `manual` rendering mode.- Returns:
- `-1` when no new data in the `input`, `input` or `outputs` is null
-
renderThreadExecutor
-