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
Modifier and TypeClassDescriptionstatic interface
static interface
Rendering status callbackstatic enum
Rendering modes -
Field Summary
Fields inherited from class com.banuba.sdk.player.VerifyCloseable
mIsClosed, mTag
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a new one output to output list.void
close()
Destroy the Player.void
Evaluate the `script` in effectcom.banuba.sdk.effect_player.EffectPlayer
Get an instance of the EffectPlayercom.banuba.sdk.effect_player.Effect
Synchronous loading of an effect by namecom.banuba.sdk.effect_player.Effect
Load effect asynchronously by namecom.banuba.sdk.effect_player.Effect
loadAsync
(String effect, Player.IEffectActivatedCallback effectActivated) Load effect asynchronously by namevoid
pause()
Pause the playback of the effect.void
play()
Resume the playback of the effect.void
removeOutput
(IOutput output) Remove one output from output list.boolean
render()
Draw and present rendered result synchronously, can be used only in `manual` rendering mode.void
setEffectVolume
(float volume) Set effect audio volume.void
setRenderMode
(Player.RenderMode newRenderMode) Set rendering mode to another.void
setRenderStatusCallback
(Player.IRenderStatusCallback renderStatusCallback) Sets the rendering callbackvoid
Use new Inputvoid
Use single Input and single Output.void
Use single Input and multiple Outputs.void
Use single new Output and remove oldvoid
Use 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
-
-
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. -
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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in 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
-
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 boolean render()Draw and present rendered result synchronously, can be used only in `manual` rendering mode.- Returns:
- `false` when no new data in the `input`, `input` or `outputs` is null
-