CamKit is an open-source video recording library for Android applications. It allows users to record video from the camera, with options to enable/disable audio and switch between the front and back cameras.
Before using CamKit, make sure you have the following:
- Android Studio 4.0 or later
- Android SDK 21 or later
- JDK 1.8 or later
To use CamKit in your Android project, follow these steps:
- Add it in your root
build.gradle
at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Add the following dependencies in you app level gradle file if not exists:
dependencies {
implementation 'com.github.MissDaizy:CamKit_Library:Tag'
}
To use CamKit in your Android application, follow these steps:
- Create two composable Screens instances of VideoPreviewScreen and VideoCaptureScreen using Navigation componenent - NavHost:
class MainActivity : ComponentActivity() {
@RequiresApi(Build.VERSION_CODES.P)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
CamKitTheme {
val navController = rememberNavController()
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {
NavHost(
navController = navController,
startDestination = Route.VIDEO
) {
composable(Route.VIDEO) {
VideoCaptureScreen(navController = navController)
}
composable(Route.VIDEO_PREVIEW_FULL_ROUTE) {
val uri = it.arguments?.getString(VIDEO_PREVIEW_ARG) ?: ""
VideoPreviewScreen(uri = uri)
}
}
}
}
}
}
}
Screen of Video Capturing with with Two Buttons - Microphone and Switching Camera from front <---> back
-
Parameters
navController
- the nav conroller that navigates between screens. -
Example
composable(Route.VIDEO) {
VideoCaptureScreen(navController = navController)
}
- Screenshot
Screen of Video Preview for previewing the video which was recorded now.
-
Parameters
uri
- the uri of the video which was recorded so it can display the video on the screen. -
Example
composable(Route.VIDEO_PREVIEW_FULL_ROUTE) {
val uri = it.arguments?.getString(VIDEO_PREVIEW_ARG) ?: ""
VideoPreviewScreen(uri = uri)
}
- Screenshot