SDK for Android

v.1.8.6
Primis Android SDK latest version is 1.8.6, Download from here

Android SDK Version History

Apps built with the Primis Player SDK for Android will obtain a fully working Primis player with most of its web functionalities.

Key Supported Features:

  • Skins
  • Layouts
  • Playlists
  • Monetization
  • Floating mode
  • Viewability detection

Requirements

ItemNotes
Android StudioIDE for Android
Android SDK versionThe minimum Android SDK version is 5.0 (API level 21)
Primis placement IDReach out to your Pub. Success Manager at Primis for more details
Primis SDKLatest version
Google IMA SDK for AndroidVersion 3.22.3, Implementation steps below

Basic Terms

A few terms to be familiar with before we start:

Primis player - A Web-based video player running inside a WebView
Primis SDK - An Android library providing essential native functionality
Floating player/unit/mode- A floating Primis player that can be located on the screen according to placement settings
Player container - A FrameLayout that is used as Primis player view container when it is not in floating mode
Flow parent - The view group of type FrameLayout to be used as the floating player container
Placement ID - A unique identifier for the player set of settings predefined in the Primis dashboard


General Installation

  • Primis monetization services require Google IMA SDK. See instructions below.
  • Follow the guidelines below to get the PrimisPlayer library by Gradle or manual download.

Gradle Setup

  1. Add the following code to your repositories block
  repositories {
    maven {
            name = "GitHubPackages"
            url = uri("https://maven.pkg.github.com/PrimisTech/PrimisPlayer-android")
            credentials {
                    username = 'token'
                    password = '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'
        }
    }
  }
  1. Add the following code to the app-level “build.gradle” to import Primis Player and Google IMA:
dependencies {
    ....
    // Primis player SDK // 
    implementation 'tech.primis:player:X.X.X'

    // Support for Google IMA SDK
    implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.22.3'
    ....
  }

Manual Download

  1. Download Primis SDK from here

  2. Add Primis .aar file (primisplayer-release-vX.X.X.aar) to "Project-Name/app/libs" folder.

  1. Add the .aar file as a dependency. See Android documentation
  2. Add the following code to app-level “build.gradle”:
dependencies {

    ....
   
    // Used by PrimisPlayer
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'com.google.android.gms:play-services-ads:20.0.0'
    implementation 'androidx.preference:preference-ktx:1.1.1'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2'

    // Support for Google IMA SDK
    implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.22.3'

    ....

}
  1. In the gradle.properties file, set “android.useAndroidX” and “android.enableJetifier” to true. These plugin files enable you to use androidx-namespaced libraries in your project. If you are using a current version of Android Studio, the gradle.properties file should already contain these settings.

Proguard Settings

If you are using proguard to build your app, add the following rule:

-keep class tech.primis.player** {*;}

In addition, follow Google’s proguard instructions for IMA SDK here

Adding Primis player

  1. To import Primis Player add the following:
import tech.primis.player.PrimisPlayer
  1. Create a Primis player variable. This view contains the Primis player and all of its functionality. The PrimisPlayer class is an extension of FrameLayout and therefore may be added to any ViewGroup type.
    Please note that we support the creation of exactly one Primis player per view.
var primisPlayer: PrimisPlayer = PrimisPlayer(applicationContext)
  1. Create Primis configuration list object of type List<PrimisPlayer.param>() and add the following:
var config = listOf(

 // The placement ID
 PrimisPlayer.param("placementId", "123456")
)
  1. Set the config object to PrimisPlayer.
primisPlayer.setConfig(config)

📘

Note

Since Primis SDK version 1.6.0 there is no need to add any code for integrating the floating unit. The floating option can be activated from the Primis dashboard. For advanced configuration only, please refer to this section and contact your Publisher Success Manager.


Player Destruction

Remove the player when the View is about to be destroyed (e.g. onDestroy(), onDestroyView()).

The destruction of the player is handled internally in the SDK when the player is detached from view.

primisPlayer?.let {
  it.remove()
  primisPlayer = null
}

📘

Note

  • In RecyclerView call the above from within the onDetachedFromRecyclerView(recyclerView: RecyclerView).
  • We recommend that you’d also set the PrimisPlayer instance to null after calling remove()

Implementation type

According to your implementation type, continue to one of the sections below:

Android SDK Advanced Features

For advanced features please use this guide