record çaudio on video recording

This commit is contained in:
Urko. 2024-01-31 07:40:49 +01:00
parent 5dee3a20bb
commit cc9c080012
1 changed files with 5 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package com.urkob.wittrail_android package com.urkob.wittrail_android
import android.annotation.SuppressLint
import android.app.Notification import android.app.Notification
import android.app.NotificationChannel import android.app.NotificationChannel
import android.app.NotificationManager import android.app.NotificationManager
@ -93,7 +94,6 @@ class RecordingService : LifecycleService() {
} }
} }
private fun createNotification(): Notification { private fun createNotification(): Notification {
val notificationIntent = Intent(this, MainActivity::class.java) val notificationIntent = Intent(this, MainActivity::class.java)
val pendingIntent = PendingIntent.getActivity( val pendingIntent = PendingIntent.getActivity(
@ -157,6 +157,7 @@ class RecordingService : LifecycleService() {
} }
// Implements VideoCapture use case, including start and stop capturing. // Implements VideoCapture use case, including start and stop capturing.
@SuppressLint("MissingPermission")
private fun captureVideo() { private fun captureVideo() {
if (!isCameraInitialized) { if (!isCameraInitialized) {
Log.e(tag, "Camera not initialized yet.") Log.e(tag, "Camera not initialized yet.")
@ -199,6 +200,9 @@ class RecordingService : LifecycleService() {
Log.e(tag, "mediaStoreOutputOptions") Log.e(tag, "mediaStoreOutputOptions")
recording = videoCapture.output recording = videoCapture.output
.prepareRecording(this, mediaStoreOutputOptions) .prepareRecording(this, mediaStoreOutputOptions)
.apply {
withAudioEnabled()
}
.start(ContextCompat.getMainExecutor(this)) { recordEvent -> .start(ContextCompat.getMainExecutor(this)) { recordEvent ->
when(recordEvent) { when(recordEvent) {
is VideoRecordEvent.Start -> { is VideoRecordEvent.Start -> {