项目地址:nanchen2251/ScreenRecordHelper
简介: ?Android screen record helper, Android 屏幕录制https://github.com/nanchen2251/ScreenRecordHelper
标签:
?screen record helper https://github.com/nanchen2251/ScreenRecordHelper
Step 1. Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.nanchen2251:ScreenRecordHelper:1.0.2'
}
Step 3. Just use it in your project
// start screen record
if (screenRecordHelper == null) {
screenRecordHelper = ScreenRecordHelper(this, null, PathUtils.getExternalStoragePath() + "/nanchen")
}
screenRecordHelper?.apply {
if (!isRecording) {
// if you want to record the audio,you can set the recordAudio as true
screenRecordHelper?.startRecord()
}
}
// You must rewrite the onActivityResult
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && data != null) {
screenRecordHelper?.onActivityResult(requestCode, resultCode, data)
}
}
// just stop screen record
screenRecordHelper?.apply {
if (isRecording) {
stopRecord()
}
}