ScreenRecordLibrary

Intro

ScreenRecord library is used to capture screen for devices with android 5.0 and above. It used the latest Media Projection API exposed by android since API level 21.

Demo

If you want to use this library in your code, you can download the project, and refer to app module in the code.

If you just want to use this Screen Record Tool, you can download it from google play or 应用宝

Usage

This library is uploaded to sonatype, you can use it following these steps:

1. add sonatype repository in your build.gradle

allprojects {

repositories {

jcenter()

mavenCentral()

maven {

url 'https://oss.sonatype.org/content/groups/public'

}

}

need to compile this library

compile 'com.github.charlesjean:recordlibrary:0.0.2'

after you acquire media projection permission from user, you need to start screen record service with the following code

Intent intent = new Intent(this, RecordService.class);

int width = ParameterManager.getInstance(this).getVideoWidth();

int height = ParameterManager.getInstance(this).getVideoHeight();

boolean needAudio = ParameterManager.getInstance(this).needAudio();

boolean isLandScapeMode = ParameterManager.getInstance(this).isLandScapeModeOn();

int quality = ParameterManager.getInstance(this).getVideoQuality();

intent.putExtra(RecordConst.RECORD_INTENT_RESULT, resultCode);

intent.putExtra(RecordConst.RECORD_DATA_INTENT, data);

intent.putExtra(RecordConst.KEY_RECORD_SCREEN_WITH, width);

intent.putExtra(RecordConst.KEY_RECORD_SCREEN_HEIGHT, height);

intent.putExtra(RecordConst.KEY_RECORD_NEED_AUDIO, needAudio);

intent.putExtra(RecordConst.KEY_RECORD_IS_LANDSCAPE, isLandScapeMode);

intent.putExtra(RecordConst.KEY_VIDEO_QUALITY, quality);

intent.putExtra(RecordConst.KEY_VIDEO_DIR, getResources().getString(R.string.save_dir));

intent.putExtra(RecordConst.KEY_NOTIFICATION_ICON, R.drawable.ic_launcher);

startService(intent);

For more detail, you can refer to the demo project.

License

This library is under Apache License, Version 2.0, not including the demo project.

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐