debug: Add PoC for recurring video

This commit is contained in:
Myzel394 2023-11-25 15:29:42 +01:00
parent 63198c316e
commit 0de720ccf4
No known key found for this signature in database
GPG Key ID: 79CC92F37B3E1A2B
2 changed files with 27 additions and 6 deletions

View File

@ -101,10 +101,25 @@ class VideoService : LifecycleService() {
scope.launch {
delay(15000)
result.stop()
// Unbind use cases before rebinding
cameraProvider?.unbindAll()
// Bind use cases to camera
cameraProvider?.bindToLifecycle(this@VideoService, cameraSelector, videoCapture)
delay(5000)
val recording = videoCapture.output.prepareRecording(this@VideoService, options)
.withAudioEnabled()
val result = recording.start(ContextCompat.getMainExecutor(this@VideoService), {})
delay(15000)
result.stop()
cameraProvider.unbindAll()
stopSelf()
stopForeground(STOP_FOREGROUND_REMOVE)
}
}, ContextCompat.getMainExecutor(this))
}

View File

@ -1,9 +1,13 @@
package app.myzel394.alibi.ui.screens
import android.content.Intent
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.core.content.ContextCompat
import app.myzel394.alibi.services.VideoService
@ -12,10 +16,12 @@ import app.myzel394.alibi.services.VideoService
fun POCVideo() {
val context = LocalContext.current
LaunchedEffect(Unit) {
val intent = Intent(context, VideoService::class.java)
ContextCompat.startForegroundService(context, intent)
Box(modifier = Modifier.fillMaxSize()) {
Button(onClick = {
val intent = Intent(context, VideoService::class.java)
ContextCompat.startForegroundService(context, intent)
}) {
Text("Start")
}
}
Text(text = "POCVideo")
}