SDK for Android

v.1.7.1
Primis Android SDK latest version is 1.7.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

Item

Notes

Android Studio

IDE for Android

Android SDK version

The minimum Android SDK version is 5.0 (API level 21)

Primis placement ID

Reach out to your Pub. Success Manager at Primis for more details

Primis SDK

Latest version 1.7.1

Google IMA SDK for Android

Version 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

651651

General Installation

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

Gradle Setup

  1. Add a Maven repository to the app-level “build.gradle”:
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”:
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'
    ....
  }

📘

Note

Note: if you previously integrated PrimisPlayer as a manual download, you were instructed to add dependencies to your app-level build.gradle (see #4 in the Manual Download option). You can remove them now from your build.gradle file.

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.

523523
  1. Add the following code to project-level “build.gradle”:
allprojects {
 repositories {
  google()
  jcenter()

  flatDir {
   dirs 'libs'
  }
 }
}
  1. Add the following code to app-level “build.gradle”:
dependencies {

    ....
    

    // Primis player SDK // 
    implementation 'primis.tech:primisplayer-release:[email protected]'

    // 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)

📘

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
}
  • 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


Did this page help you?