diff --git a/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera1Impl.kt b/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera1Impl.kt index 3631d95..0223c3d 100644 --- a/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera1Impl.kt +++ b/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera1Impl.kt @@ -4,11 +4,13 @@ package fr.g123k.torch_compat.impl import android.content.Context import android.content.pm.PackageManager +import android.graphics.SurfaceTexture; import android.hardware.Camera class TorchCamera1Impl(private val context: Context) : BaseTorch() { private var camera: Camera? = null + private var surface: SurfaceTexture? = null private fun initCamera(): Camera? { if (camera == null) { @@ -17,6 +19,8 @@ class TorchCamera1Impl(private val context: Context) : BaseTorch() { } catch (e: Exception) { null } + surface = SurfaceTexture(0) + camera?.setPreviewTexture(surface) } return camera @@ -51,8 +55,9 @@ class TorchCamera1Impl(private val context: Context) : BaseTorch() { } override fun dispose() { + surface?.release() camera?.release() camera = null } -} \ No newline at end of file +}