Class Player

All Implemented Interfaces:
Closeable, 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.
  • 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

      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 interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class VerifyCloseable
    • 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 it
      output - 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 it
      outputs - 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(String effect, Player.IEffectActivatedCallback effectActivated)
      Load effect asynchronously by name
      Parameters:
      effect - path to the effect or effect name
      effectActivated - effect activation listener
    • loadAsync

      @Nullable public com.banuba.sdk.effect_player.Effect loadAsync(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(String effect)
      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 execute
      resultCallback - 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