Package com.banuba.sdk.player
Class Player
- java.lang.Object
-
- com.banuba.sdk.player.VerifyCloseable
-
- com.banuba.sdk.player.Player
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class Player extends VerifyCloseable
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 Classes Modifier and Type Class Description static interface
Player.IEffectActivatedCallback
static interface
Player.IRenderStatusCallback
Rendering status callbackstatic class
Player.RenderMode
Rendering modes
-
Field Summary
-
Fields inherited from class com.banuba.sdk.player.VerifyCloseable
mIsClosed, mTag
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addOutput(IOutput output)
Add a new one output to output list.void
close()
Destroy the Player.void
evalJs(java.lang.String script, com.banuba.sdk.effect_player.JsCallback resultCallback)
Evaluate the `script` in effectcom.banuba.sdk.effect_player.EffectPlayer
getEffectPlayer()
Get an instance of the EffectPlayercom.banuba.sdk.effect_player.Effect
load(java.lang.String effect)
Synchronous loading of an effect by namecom.banuba.sdk.effect_player.Effect
loadAsync(java.lang.String effect)
Load effect asynchronously by namecom.banuba.sdk.effect_player.Effect
loadAsync(java.lang.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(IInput input)
Use new Inputvoid
use(IInput input, IOutput output)
Use single Input and single Output.void
use(IInput input, IOutput[] outputs)
Use single Input and multiple Outputs.void
use(IOutput output)
Use single new Output and remove oldvoid
use(IOutput[] outputs)
Use new Output's and remove old-
Methods inherited from class com.banuba.sdk.player.VerifyCloseable
finalize
-
-
-
-
Method Detail
-
setRenderMode
public void setRenderMode(Player.RenderMode newRenderMode)
Set rendering mode to another. By default, the render mode is set to LOOP.- Parameters:
newRenderMode
- new rendering mode
-
setRenderStatusCallback
public void setRenderStatusCallback(Player.IRenderStatusCallback renderStatusCallback)
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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- 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
public void use(@Nullable IInput input)
Use new Input- Parameters:
input
- frames will be receive from it
-
use
public void use(@Nullable IOutput output)
Use single new Output and remove old- Parameters:
output
- processed frames will be push to it
-
use
public void use(@Nullable IOutput[] outputs)
Use new Output's and remove old- Parameters:
outputs
- processed frames will be push to these outputs
-
use
public void use(@Nullable IInput input, @Nullable IOutput output)
Use single Input and single Output.- Parameters:
input
- frames will be receive from itoutput
- processed frames will be push to it
-
use
public void use(@Nullable IInput input, @Nullable IOutput[] outputs)
Use single Input and multiple Outputs.- Parameters:
input
- frames will be receive from itoutputs
- processed frames will be push to these outputs
-
addOutput
public void addOutput(@NonNull IOutput output)
Add a new one output to output list.- Parameters:
output
- processed frames will be push to it
-
removeOutput
public void removeOutput(@NonNull IOutput output)
Remove one output from output list.- Parameters:
output
- delete this output from outputs
-
loadAsync
@Nullable public com.banuba.sdk.effect_player.Effect loadAsync(java.lang.String effect, Player.IEffectActivatedCallback effectActivated)
Load effect asynchronously by name- Parameters:
effect
- path to the effect or effect nameeffectActivated
- effect activation listener
-
loadAsync
@Nullable public com.banuba.sdk.effect_player.Effect loadAsync(java.lang.String effect)
Load effect asynchronously by name- Parameters:
effect
- path to the effect or effect name
-
load
@Nullable public com.banuba.sdk.effect_player.Effect load(java.lang.String effect)
Synchronous loading of an effect by name- Parameters:
effect
- path to the effect or effect name
-
evalJs
public void evalJs(@NonNull java.lang.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
-
-