scrcast

A fully, featured replacement for screen recording needs backed by Kotlin with the power of Coroutines and Android Jetpack. scrcast is:

  • Easy to use: scrcast's API leverages Kotlin languages features for simplicity, ease of use, and little-to-no boilerplate. Simply configure and record()
  • Modern: scrcast is Kotlin-first and uses modern libraries including Coroutines and Android Jetpack.

Download

scrcast is available on jitpack().

In your root build.gradle:

allprojects {
    repositories {
        google()
        jcenter()
+        maven {
+            url "https://jitpack.io"
+        }
    }
}

implementation ("dev.bmcreations:scrcast:0.1.0")

Quick Start

scrcast provides a variety of configuration options for capturing, storing, and providing user interactions with your screen recordings.

Configuring

val recorder = ScrCast.use(activity)
recorder.apply {
    // configure options via DSL
    options {
        video {
            maxLengthSecs = 360
        }
        storage {
            directoryName = "scrcast-sample"
        }
        notification {
            title = "Super cool library"
            description = "shh session in progress"
            icon = resources.getDrawable(R.drawable.ic_camcorder, null).toBitmap()
            channel {
                id = "1337"
                name = "Recording Service"
            }
            showStop = true
            showPause = true
            showTimer = true
        }
        moveTaskToBack = false
        startDelayMs = 5_000
    }
}

You can find full configuration details and documentation here.

State

interaction with MediaRecorderis abstracted in a easy to use and manage interface, via explict state-changing accessors.

Start

recorder.record()

Stop

recorder.stopRecording()

Pause

recorder.pause()

Resume

recorder.resume()

Callbacks

State changes are emitted via RecordingCallbacks as a single interface or via a discrete lambda onRecordingStateChange

Completed recording output file is also emittable in RecordingCallbacks via

fun onRecordingFinished(file: File)

Requirements

  • AndroidX
  • minSdkVersion 23+
  • compileSdkVersion 28+
  • Java 8+

Gradle (.gradle)

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

Gradle Kotlin DSL (.gradle.kts)

android {
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}

tasks.withType<KotlinCompile> {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

GitHub