# Installation

Follow these steps to install ByteArk Player SDK in an Android project.

# 1. Configure settings.gradle

Add Maven repositories under pluginManagement:

pluginManagement {
  repositories {
      ...
+   maven {
      url 'https://raw.githubusercontent.com/NielsenDigitalSDK/nielsenappsdk-android/master/'
    }
    ...
  }
}
1
2
3
4
5
6
7
8
9

Add the ByteArk Maven repository under dependencyResolutionManagement:

dependencyResolutionManagement {
  repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  repositories {
    google()
    mavenCentral()
+     maven {
        url "https://gitlab.inox.co.th/api/v4/projects/1158/packages/maven"
        credentials(HttpHeaderCredentials) {
          name = "Private-Token"
          value = "$gitLabPrivateToken"
      }
      authentication {
        header(HttpHeaderAuthentication)
      }
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

You will receive gitLabPrivateToken from the ByteArk team. Place it in gradle.properties or local.properties of your project.

# 2. Add the dependency in app/build.gradle

dependencies {
  implementation 'com.byteark:byteark-player-sdk:<VERSION>'
}
1
2
3

# 3. Configure AndroidManifest.xml

Add the required permissions:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
1
2
3
4
5

Enable cleartext traffic if you need to play non-HTTPS content (not recommended for production):

<application
    ...
    android:usesCleartextTraffic="true">
1
2
3

Add the ByteArk Player service:

<application
     ...
    >
    ...
    <service android:name="com.byteark.bytearkplayercore.handler.exoplayer.service.ByteArkPlayerService"
        android:enabled="true"
        android:exported="true"/>
    ...
</application>
1
2
3
4
5
6
7
8
9

If you plan to use Chromecast, add the Cast options provider:

<application>
    <meta-data
        android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
        android:value="com.google.android.exoplayer2.ext.cast.DefaultCastOptionsProvider"/>
</application>
1
2
3
4
5

# 4. Configure the activity

For full-screen and Picture-in-Picture, set the activity attributes:

<activity
    android:name=".YourActivity"
    android:screenOrientation="portrait"
    android:supportsPictureInPicture="true"
    android:launchMode="singleTask"
    android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
    android:exported="true"
    android:theme="@style/Theme.App.Starting">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
            <category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
        </intent-filter>
    </activity>
1
2
3
4
5
6
7
8
9
10
11
12
13
14

# License key

ByteArk Player SDK for Android requires a license key. Contact sales@byteark.com to request your license key.

The license key is used when creating ByteArkPlayerBuilder via withLicenseKey(...):

val playerBuilder = ByteArkPlayerBuilder.Builder()
  .withContext(this)
  .withLicenseKey("<YOUR_LICENSE_KEY>")
  .withAutoPlay()
  .withControl()
  .build()
1
2
3
4
5
6

You're ready to start using the SDK — see Using the SDK.