SDK for Android

v1.11.1

Primis Android SDK latest version is 1.11.1, 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.28.2, 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.28.2'
	....
  }

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.9'
    implementation 'com.google.android.gms:play-services-ads:21.1.0'
    implementation 'androidx.preference:preference-ktx:1.1.1'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1'

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

	....

}
  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 and configure a PrimisPlayer instance using PrimisConfiguration.Builder class:
    Declare a nullable variable that will hold the PrimisPlayer instance:
    var primisPlayer: PrimisPlayer?
    
    Use the PrimisConfiguration.Builder to create a configured PrimisPlayer instance:
    primisPlayer = PrimisConfiguration.Builder()
    .placement("123456")
    .createPlayer(applicationContext)
    

📘

Note

Using PrimisPlayr.param to set the player’s configuration is deprecated since SDK version 1.9.0

📘

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


Sample Application

Check out our sample application on GitHub and see the Primis SDK in action.

The sample app demonstrate how to integrate Primis SDK for Android. Be sure to read the README file for detailed setup instructions and usage guidelines.