Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new VideoCapture. #1

Merged
merged 1 commit into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added new VideoCapture.
31st October, 2022
Golam Shakib Khan
  • Loading branch information
golamshakib authored and golamshakib committed Oct 31, 2022
commit f3f09068dae77e111a889667ffcbf09bcf46c941
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.camera:camera-video:1.1.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down Expand Up @@ -88,7 +89,7 @@ afterEvaluate {

groupId = 'com.github.ShaQib07'
artifactId = 'MediaPicker'
version = '0.9.1'
version = '1.0.0'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import android.widget.SeekBar
import androidx.activity.viewModels
import androidx.camera.core.*
import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.camera.video.*
import androidx.camera.video.VideoCapture
import androidx.core.content.ContextCompat
import androidx.core.net.toUri
import com.shakib.mediapicker.R
Expand All @@ -37,7 +39,7 @@ class CameraActivity : BaseActivity<ActivityCameraBinding>() {
private val clickedImages: ArrayList<Image> = ArrayList()

private var imageCapture: ImageCapture? = null
private var videoCapture: VideoCapture? = null
private var videoCapture: VideoCapture<Recorder>? = null
private var mediaPlayer: MediaPlayer? = null
private var cameraExecutor: ExecutorService? = null
private var preferredCamera = CameraSelector.DEFAULT_BACK_CAMERA
Expand Down Expand Up @@ -166,12 +168,15 @@ class CameraActivity : BaseActivity<ActivityCameraBinding>() {
// Bind use cases to camera
if (isVideo) {
// The Configuration of how we want to capture the video
videoCapture = VideoCapture.Builder().apply {
setTargetAspectRatio(AspectRatio.RATIO_16_9)
setCameraSelector(preferredCamera)
setVideoFrameRate(30)
setTargetRotation(binding.viewFinder.display.rotation)
}.build()
val qualitySelector = QualitySelector.fromOrderedList(
listOf(Quality.UHD, Quality.FHD, Quality.HD, Quality.SD),
FallbackStrategy.lowerQualityOrHigherThan(Quality.SD))
val recorder = cameraExecutor?.let {
Recorder.Builder()
.setExecutor(it).setQualitySelector(qualitySelector)
.build()
}
recorder?.let { videoCapture = VideoCapture.withOutput(it) }

cameraProvider.bindToLifecycle(this, preferredCamera, videoCapture, preview)
.also { cameraControl = it.cameraControl }
Expand Down