Skip to main content

Before instantiating DIVA Player

  • In the settings.gradle file, in the repositories section, add:
    maven { url 'https://jitpack.io' }
    maven { url "https://npaw.jfrog.io/artifactory/youbora/" }

Basic instantiation code (Mobile)

In the build.gradle (Module :app) file, add the following dependency:

implementation 'com.deltatre.diva:diva-mobile-divaboadapter:<latest-version>'

Under the layout folder, in the activity_main.xml file, add a fragment container view to the layout file:

<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

In the AndroidManifest.xml file, add the PiP capability to the Activity that contains the DIVA fragment (because DIVA requires the Picture-in-Picture feature):

<activity
...
android:supportsPictureInPicture="true">
...
</activity>

Given <videoId>, <settingsURL>, <languageCountryCode>, <userToken> and <sharedKey> the following code (MainActivity.kt) streams the corresponding video:

package com.example.divaplayerhelloworld20

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.deltatre.divaboadapter.DivaBoAdapterMobile
import com.deltatre.divaboadapter.DivaExtraParamsMobile
import androidx.lifecycle.lifecycleScope

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_main)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}

val divaExtraParameters = DivaExtraParamsMobile()

val boAdapter = DivaBoAdapterMobile(this /*refers to the Activity class */, lifecycleScope)

boAdapter.createDivaFragment(
adapterSettingsUrl = "<settingsURL>",
langCountryCode = "<languageCountryCode>",
videoId = "<videoId>",
getCurrentUserAccountAccessToken = {
//Get the user token
"<userToken>"
},
sharedKey = "<sharedKey>",
conf = divaExtraParameters,
version = null,
onError = { exception ->
//On Error
}) { divaFragment ->
supportFragmentManager
.beginTransaction()
.replace(R.id.fragment_container_view, divaFragment)
.commit()
}
}
}

Basic instantiation code (TV)

In the build.gradle (Module :app) file, add the following dependency:

implementation 'com.deltatre.diva:diva-tv-divaboadapter:<latest-version>'

Under the layout folder, in the activity_main.xml file, add a fragment container view to the layout file:

<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

In the AndroidManifest.xml file, add the LeanBack support as following:

<uses-feature
android:name="android.software.leanback"
android:required="true" />

<activity
...
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
...
</activity>

Given <videoId>, <settingsURL>, <languageCountryCode>, <userToken> and <sharedKey> the following code (MainActivity.kt) streams the corresponding video:

package com.example.divaplayerhelloworld20

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.deltatre.divaboadapter.DivaBoAdapterTV
import com.deltatre.divaboadapter.DivaExtraParams
import androidx.lifecycle.lifecycleScope

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val divaExtraParameters = DivaExtraParams()

val boAdapter = DivaBoAdapterTV(this /*refers to the Activity class */, lifecycleScope)

boAdapter.createDivaFragment(
adapterSettingsUrl = "<settingsURL>",
langCountryCode = "<languageCountryCode>",
videoId = "<videoId>",
getCurrentUserAccountAccessToken = {
//Get the user token
"<userToken>"
},
sharedKey = "<sharedKey>",
conf = divaExtraParameters,
version = null
onError = { exception ->
//On Error
}) { divaFragment ->
supportFragmentManager
.beginTransaction()
.replace(R.id.fragment_container_view, divaFragment)
.commit()
}
}
}