WebView Implementation

Android SDK

Adding Primis Player to a WebView presenting HTML content

  1. Adding an Html Div element to the web page

PrimisPlayer is overlaid on top of the web content in this type of integration. The Html page has to contain a div element that will mark the player's position and width. Its height will be updated later by PrimisPlayer.

Add an Html div element to your web page with id=”primisPlayerSdkPlaceholder”

<div id="primisPlayerSdkPlaceholder"></div>


  1. You may wish to include style attributes to control position and width.
    for example:
    <div id="primisPlayerSdkPlaceholder", style="width: 90%; margin:auto;">

  2. It is required that the div element will have opening and closing tags.
    Do not do:
    <div id="primisPlayerSdkPlaceholder”/>

  1. Initializing and configuring the player

Add an instance variable for the Primis player:

var primisPlayer: PrimisPlayer? = null
  1. Adding an interface to allow PrimisPlayer to identify changes in the web page content height
private lateinit var primisJSInterface: PrimisScrollJSInterface


primisJSInterface = PrimisScrollJSInterface()
    primisJSInterface, PrimisScrollJSInterface.Companion.PRIMIS_SCROLL_JS_INTERFACE_OBJ

  1. Initializing the player

Implement the WebViewClient interface method onPageFinished and Initialize the player inside it. The player will require a placementId string and your WebView.

webView.webViewClient = object : WebViewClient() {

  override fun onPageFinished( view: WebView, url: String) {
       	super.onPageFinished(view, url)
        // Initialize the PrimisPlayer here
        primisPlayer = PrimisConfiguration.Builder()
    				.placement("123456")// The placement ID
      			.hostAppWebView(webView) // The WebView
    				.hostAppWebViewJSInterface(primisJSInterface) // The WebView interface


In case of using WEB GDPR Consent you need to set the host application Consent Type as Consent.Type.WEB_CONSENT. For more information on how to set it please refer to the “Consent” section under “Advanced features”.

  1. Removing Primis Player

Call PrimisPlayer.remove when the view is about to be destroyed (e.g. onDestroy(), onDestroyView())

primisPlayer?.let {
  primisPlayer = null