Skip to content

Commit

Permalink
Merge pull request #1 from ShaQib07/release/1.0.0
Browse files Browse the repository at this point in the history
Added new VideoCapture.
  • Loading branch information
ShaQib07 authored Oct 31, 2022
2 parents 2113054 + f3f0906 commit 111dd2b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
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

0 comments on commit 111dd2b

Please sign in to comment.