-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 03226fc
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Setup | ||
1. Put .aar file into your module's **libs** dir | ||
2. Add following lines to **repository** section of your module's build.gradle: | ||
```groovy | ||
flatDir { | ||
dirs 'libs' | ||
} | ||
``` | ||
3. Declare following dependencies: | ||
```groovy | ||
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](https://github.com/coub/coub-android-library/releases) page | ||
# Usage | ||
## Using built-in view: | ||
```kotlin | ||
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) | ||
``` | ||
## Using your own custom view: | ||
```kotlin | ||
val coubPlayer = CoubPlayer.Factory.getInstance(context) | ||
coubPlayer.setOutputTexture(textureView) | ||
coubPlayer.load(coubUrl) // https://coub.com/view/${permalink} | ||
coubPlayer.setPlayWhenReady(true) | ||
``` | ||
## Receiving playback events | ||
```kotlin | ||
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 | ||
} | ||
}) | ||
``` | ||
## Adjusting volume and restarting | ||
```kotlin | ||
coubPlayer.volume = newVolume // 0f..1f | ||
coubPlayer.restart() | ||
``` | ||
## Release player when you no longer need it | ||
```kotlin | ||
coubPlayer.release() | ||
``` |
Binary file not shown.