David Zhao

updated readme

<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="KotlinThrowableNotThrown" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>
</component>
\ No newline at end of file
# client-sdk-android
# Android Kotlin SDK for LiveKit
## Setup
Official Android Client SDK for [LiveKit](https://github.com/livekit/livekit-server). Easily add video & audio capabilities to your Android apps.
Requires `protocol` repo to exist at the same level as this repo to generate protobufs correctly.
## Docs
### Optional (Dev convenience)
Docs and guides at [https://docs.livekit.io](https://docs.livekit.io)
1. Download webrtc sources from https://webrtc.googlesource.com/src
2. Add sources to Android Studio by pointing at the `webrtc/sdk/android` folder.
## Installation
LiveKit for Android is available as a Maven package.
```groovy title="build.gradle"
...
dependencies {
implementation "io.livekit:livekit-android:<version>"
}
```
## Usage
LiveKit uses WebRTC-provided `org.webrtc.SurfaceViewRenderer` to render video tracks. Subscribed audio tracks are automatically played.
```kt
class MainActivity : AppCompatActivity(), RoomListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
val url = "wss://your_host";
val token = "your_token"
## Publishing releases
launch {
val room = LiveKit.connect(
applicationContext,
url,
token,
ConnectOptions(),
this
)
val localParticipant = room.localParticipant
val audioTrack = localParticipant.createAudioTrack()
localParticipant.publishAudioTrack(audioTrack)
val videoTrack = localParticipant.createVideoTrack()
localParticipant.publishVideoTrack(videoTrack)
videoTrack.startCapture()
1. Ensure you have your `.gradle/gradle.properties` filled with the requisite credentials:
attachVideo(videoTrack, localParticipant)
}
}
````
nexusUsername=<sonatype username>
nexusPassword=<sonatype password>
signing.keyId=<signing key id>
signing.password=<signing key password>
signing.secretKeyRingFile=<signing pgp key path>
````
override fun onTrackSubscribed(
track: Track,
publication: RemoteTrackPublication,
participant: RemoteParticipant,
room: Room
) {
if (track is VideoTrack) {
attachVideo(track, participant)
}
}
2. Update `VERSION_NAME` in `gradle.properties` to reflect the release version. (Remove "-SNAPSHOT" when releasing.)
3. Run `gradle publish closeAndReleaseRepository` to upload to maven.
4. Update `VERSION_NAME` in `gradle.properties` to prepare for next release version.
private fun attachVideo(videoTrack: VideoTrack, participant: Participant) {
// viewBinding.renderer is a `org.webrtc.SurfaceViewRenderer` in your
// layout
videoTrack.addRenderer(viewBinding.renderer)
}
}
```
## Dev Environment
To develop the Android SDK itself, you'll need
- Check out the [protocol](https://github.com/livekit/protocol) repo to exist at the same level as this repo.
- Install [Android Studio Arctic Fox Beta](https://developer.android.com/studio/preview)
### Optional (Dev convenience)
1. Download webrtc sources from https://webrtc.googlesource.com/src
2. Add sources to Android Studio by pointing at the `webrtc/sdk/android` folder.
... ...
... ... @@ -11,7 +11,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0-beta04'
classpath 'com.android.tools.build:gradle:7.0.0-beta05'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
... ...
## Publishing releases
1. Ensure you have your `.gradle/gradle.properties` filled with the requisite credentials:
````
nexusUsername=<sonatype username>
nexusPassword=<sonatype password>
signing.keyId=<signing key id>
signing.password=<signing key password>
signing.secretKeyRingFile=<signing pgp key path>
````
2. Update `VERSION_NAME` in `gradle.properties` to reflect the release version. (Remove "-SNAPSHOT" when releasing.)
3. Run `gradle publish closeAndReleaseRepository` to upload to maven.
4. Update `VERSION_NAME` in `gradle.properties` to prepare for next release version.
... ...
... ... @@ -108,8 +108,8 @@ class MainActivity : AppCompatActivity() {
const val PREFERENCES_KEY_URL = "url"
const val PREFERENCES_KEY_TOKEN = "token"
const val URL = "ws://192.168.11.5:7880"
const val URL = "wss://livekit.watercooler.fm"
const val TOKEN =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MTk0NDkwNTMsImlzcyI6IkFQSXdMZWFoN2c0ZnVMWURZQUplYUtzU0UiLCJqdGkiOiJwaG9uZTIiLCJuYmYiOjE2MTY4NTcwNTMsInZpZGVvIjp7InJvb20iOiJteXJvb20iLCJyb29tSm9pbiI6dHJ1ZX19.OiemzgYXe5269q_VDXb912LG3QoqoKy-52-xEWcTr3A"
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE5ODQyMzE0OTgsImlzcyI6IkFQSU1teGlMOHJxdUt6dFpFb1pKVjlGYiIsImp0aSI6ImZvcnRoIiwibmJmIjoxNjI0MjMxNDk4LCJ2aWRlbyI6eyJyb29tIjoibXlyb29tIiwicm9vbUpvaW4iOnRydWV9fQ.PVx_lXAIGxcD2VRslosrbkigc777GXbu-DQME8hjJKI"
}
}
\ No newline at end of file
... ...