Skip to main content

Quick Start

Lura Android SDK is a powerful and versatile android media playback library designed to simplify the process of incorporating audio and video playback into your android applications. With Lura, developers can easily integrate media playback into their applications, providing users with a seamless, immersive playback experience. The library is packed with every feature a developer might need, from fine-tuned playback controls, playlist management, HLS & DASH support to advanced playback features such as Content Protection (DRM), Advertisement Integration and more. Lura also provides extensive documentation and support, making it an ideal choice for developers of all levels of expertise.

Import the SDK

  • Download the latest version of Lura Player SDK .aar file from the developer portal.
  • Move the .aar file to project/app/libs/ folder in your Android Studio project.
build.gradle
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

Add dependencies

build.gradle
//Kotlin
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.8.20")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.20")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0")
//ExoPlayer
implementation("com.google.android.exoplayer:exoplayer:2.18.6")

Create LuraPlayer

In order to use the LuraPlayer, first include a LuraPlayerView in your layout:

activity_main.xml
<com.akta.luraplayer.api.ui.LuraPlayerView
android:id="@+id/luraPlayer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF000000" />

Prepare variables:

MainActivity.kt
class MainActivity : AppCompatActivity() {

private lateinit var playerView: LuraPlayerView
private var player: LuraPlayer? = null
private val listener: LuraEventListener = LuraEventListener { event ->
LuraLog.d("LuraEvent", event.type.name)
}
}

Hold a reference to the LuraPlayerView in your Activity / Fragment:

MainActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
playerView = findViewById(R.id.luraPlayer)
}

Create a LuraPlayer object and pass LuraPlayerView and a Context to it:

MainActivity.kt
player = LuraPlayer(context = this, playerView = playerView)

Add listener to SDK events on IO thread

MainActivity.kt
player?.addListener(listener = listener)

Add listener to SDK events on main thread

MainActivity.kt
player?.addListener(dispatcher = Dispatchers.Main, listener = listener)

Content playback

The following steps and code sample show how to play a single media asset with the player:

  • Create a LuraConfiguration object.
  • Use the newly created LuraConfiguration object in LuraPlayer::setConfig() function.
MainActivity.kt
val luraConfiguration = LuraConfiguration(
name = "LuraPlayer",
lura = Lura(
appKey = "",
assetId = ""
)
)
player?.setConfig(luraConfiguration)

Add Activity Life-Cycle functions:

MainActivity.kt
override fun onPause() {
player?.onPause()
super.onPause()
}

override fun onResume() {
super.onResume()
player?.onResume()
}

override fun onDestroy() {
player?.destroy()
super.onDestroy()
}

Remove SDK events listener and destroy SDK:

MainActivity.kt
player?.removeListener(listener = listener)
player?.destroy()