Android SDK Advanced Features

Floating Player Preset

Based on your placement configuration, when the user scrolls the player off the screen, the player will switch to floating mode.

If you need an advanced control (e.g., the place of the flowParentView in the view tree hierarchy, dimensions etc.) you will need to follow this section and provide a floating container view group as FrameLayout, which will be used to contain the player in its floating mode.

  1. Create the floating container object as FrameLayout.
val floatingContainer: FrameLayout = FrameLayout(applicationContext)
  1. Create a FrameLayout.LayoutParams object and assign it to the floating container. It is highly recommended that you will keep these parameters for best performance and UX.
val flp = FrameLayout.LayoutParams(

floatingContainer.layoutParams = flp
  1. Add the floating container to the main view layout.
  1. Add the floating parent view by passing it to the PrimisConfiguration.Builder’s floatingPlayerContainer() function:
primisPlayer = PrimisConfiguration.Builder()

  • If floating will be activated in the dashboard, but the floating container won’t be set by the host application, PrimisPlayer will set a default one.
  • The settings of the flow parent can be made in the XML file as well.
  • We used ConstraintLayout as the main ViewGroup but you can use any ViewGroup you like.

One Player – multiple indexes in RecyclerView

PrimisPlayer can be shown in (more than one) different indexes during scrolling in RecyclerView.
In our example, we override getItemViewType(position: Int) and set to which of the cells the player will be added.

No need to instantiate the player more than once, just override getItemViewType(position: Int) and set the requested indexes.

override fun getItemViewType(position: Int): Int {
    return if (position == FIRST_INDEX || position == SECOND_INDEX || ...) {
    } else {
  • The player must be added to a recycled cells which means only one player will be shown on screen at a time.

  • Note: Do not set a floating player in the placement configuration (in Primis dashboard) if using this mode, since enabling it in this mode may result in unexpected behavior.

Player API

Primis SDK allows the host application to register and start listening to events that are triggered inside the video player (e.g., when video content starts playing or when the user clicks on an ad).

A full list of available player API events can be found here.

  1. Implement PrimisPlayerEventListener:
class YourPrimisPlayerEventListener: PrimisPlayerEventListener {
    override fun onPrimisPlayerApiEvent(event: PlayerApiEvent) {
        // Here you'll be able to extract the event's data
        when(event.eventType) {
            "videoEnd" - > {
                // This event doesn’t include a value

            "volumeChange" - > {
                val newValue =["singleValue"] as Double

            "adStarted" - > {
                val impValue =["impValue"] as Double
                val servingFee =["servingFee"] as Double

            "videoStart" - > {
                val title =["title"] as String
                val duration =["duration"] as String
  1. Set your event listener object to Primis player with the PrimisConfiguration.Builder’s eventListener() function
lateinit var primisPlayerEventListener: YourPrimisPlayerEventListener

	primisPlayerEventListener = YourPrimisPlayerEventListener()
	primisPlayer = PrimisConfiguration.Builder()


The Player API callback calls are made on a background thread.

Consent management

Primis Player supports consent strings in IAB TCF format, version 2. If your app uses certified IAB CMP, the SDK will read the consent string from:

  1. If using a native (Mobile) consent, then, the SDK will address SharedPreferences according to the standard.
  2. If using a Web consent (inside the webView) , the SDK will address the __tcfapi() according to the standard.

To set a web consent in WebView implementation (this step is not required for native consent):

// Initialize the PrimisPlayer here
primisPlayer = PrimisConfiguration.Builder()
    	.placement("123456")// The placement ID

To start the Player with some pre-defined consent string, pass it to the PrimisConfiguration.Builder object using the consent() function

primisPlayer = PrimisConfiguration.Builder()
.consent(consentString, "2")

Friendly View Registration

Primis player automatically detects when a view is overlapping the player and as a result, the player stops.

If needed, the host application can register friendly views with unique ids (of type int) to be ignored by the overlapping feature.

Please consult with the Primis team before using this feature.


  1. Add a unique id/s to ids.xml file OR set the id in the XML layout:

<item name="some_unique_id" type="id" />


  1. Create HashSet and add all of the ids needed as friendly views.
    In the case of multiple views inside a ViewGroup, only the ViewGroup’s id is needed.
val set = hashSetOf<Int>()
  1. Add the friendly views Set to PrimisConfiguration.Builder with the friendlyViews() function:
primisPlayer = PrimisConfiguration.Builder()

Landscape Support

Primis player supports landscape orientation.
If your application supports landscape you need to set the following in the manifest.xml for better UX and monetization performance:

<activity android:name=".YourPlayerActivity"

  • By adding the above the onCreate() method won’t be called after screen rotation.

Additional Parameters

There are additional configuration parameters for the player. You may add the parameters, that will be set via the PrimisConfiguration.Builder’s additionalParams() function:

primisPlayer = PrimisConfiguration.Builder()

  • The full list of available dynamic parameters can be found here.

Error Listener

In case of an error, where Primis player won’t be able to load, an “illegalPlacementEvent” will be fired via the PrimisPlayerErrorListener.onError(error: String).

In order to register to this event and get notified call setErrorListener() after instantiating PrimisPlayer like so:

primisPlayer.setErrorListener(object : PrimisPlayerErrorListener {
    override fun onError(error: String) {
        // TODO: Implement your code here...




  1. The error event is being fired on the main thread
  2. Your view manager (e.g.: Activity or Fragment) can instead implement the PrimisPlayerErrorListener and override its member function ‘onError()’