- Put .aar file into your module's libs dir
- Add following lines to repository section of your module's build.gradle:
flatDir {
dirs 'libs'
}
- Declare following dependencies:
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.+"
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.2.0'
implementation 'com.google.android.exoplayer:exoplayer-core:2.9.6'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation (name: 'player-x.y.z', ext: 'aar')
Replace x.y.z with preferred version from Releases page
val coubPlayer = CoubPlayer.Factory.getInstance(context)
coubPlayer.injectInto(containerView) // player will remove all existing views in container
coubPlayer.load(coubUrl) // https://coub.com/view/${permalink}
coubPlayer.setPlayWhenReady(true)
val coubPlayer = CoubPlayer.Factory.getInstance(context)
coubPlayer.setOutputTexture(textureView)
coubPlayer.load(coubUrl) // https://coub.com/view/${permalink}
coubPlayer.setPlayWhenReady(true)
coubPlayer.addEventListener(object : CoubPlayer.EventListener {
override fun onError(player: CoubPlayer, error: Throwable?) {
// do something
}
override fun onLoaded(player: CoubPlayer) {
// do something
}
override fun onStarted(player: CoubPlayer) {
// do something
}
override fun onStopped(player: CoubPlayer) {
// do something
}
})
coubPlayer.volume = newVolume // 0f..1f
coubPlayer.restart()
coubPlayer.release()