Class 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.
    • Constructor Summary

      Constructors 
      Constructor Description
      Player()
      Create a new instance of the Player, with frame rate 30 FPS
      Player​(int fps)
      Create a new instance of the Player, with given FPS
    • 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 effect
      com.banuba.sdk.effect_player.EffectPlayer getEffectPlayer()
      Get an instance of the EffectPlayer
      com.banuba.sdk.effect_player.Effect load​(java.lang.String effect)
      Synchronous loading of an effect by name
      com.banuba.sdk.effect_player.Effect loadAsync​(java.lang.String effect)
      Load effect asynchronously by name
      com.banuba.sdk.effect_player.Effect loadAsync​(java.lang.String effect, Player.IEffectActivatedCallback effectActivated)
      Load effect asynchronously by name
      void 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 callback
      void use​(IInput input)
      Use new Input
      void 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 old
      void use​(IOutput[] outputs)
      Use new Output's and remove old
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • 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 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 interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.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​(java.lang.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​(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 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