Media3Effect
class Media3Effect : CameraEffect, AutoCloseable
A CameraEffect that applies media3 Effect to the CameraX pipeline
This class is an adapter between the CameraX CameraEffect API and the media3 Effect API. It allows the media3 Effect to be applied to the CameraX pipeline on the fly without restarting the camera.
Code sample:
media3Effect = Media3Effect(requireContext(), PREVIEW or VIDEO_CAPTURE, executor) {
Log.e(TAG, "Error in Media3Effect: $it")
}
media3Effect.setEffects(listOf(Brightness(1.5f)))
cameraController.setEffects(setOf(media3Effect))
Summary
Public constructors |
|---|
Public functions |
|
|---|---|
open Unit |
close()Closes the |
Unit |
setEffects(effects: List<Effect>)Applies a list of media3 effects to the camera output. |
Inherited functions |
||||||||
|---|---|---|---|---|---|---|---|---|
|
Public constructors
Media3Effect
Media3Effect(
context: Context,
targets: Int,
executor: Executor,
errorListener: Consumer<Throwable>
)
| Parameters | |
|---|---|
context: Context |
the Android context |
targets: Int |
the target UseCase to which this effect should be applied. For details, see |
executor: Executor |
the |
errorListener: Consumer<Throwable> |
invoked if the effect runs into unrecoverable errors. The |
Public functions
close
open fun close(): Unit
Closes the Media3Effect and releases all the resources.
The caller should only close when the effect when it's no longer in use. Once closed, the effect should not be used again.
setEffects
fun setEffects(effects: List<Effect>): Unit
Applies a list of media3 effects to the camera output.
Once set, the effects will be effective immediately. To clear the effect, call this method again with a empty list.