Media3Effect
public final class Media3Effect extends CameraEffect implements 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 methods |
|
|---|---|
void |
close()Closes the |
final void |
setEffects(@NonNull List<@NonNull Effect> effects)Applies a list of media3 effects to the camera output. |
Inherited methods |
|---|
Public constructors
Media3Effect
public Media3Effect(
@NonNull Context context,
int targets,
@NonNull Executor executor,
@NonNull Consumer<@NonNull Throwable> errorListener
)
| Parameters | |
|---|---|
@NonNull Context context |
the Android context |
int targets |
the target UseCase to which this effect should be applied. For details, see |
@NonNull Executor executor |
the |
@NonNull Consumer<@NonNull Throwable> errorListener |
invoked if the effect runs into unrecoverable errors. The |
Public methods
close
public void close()
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
public final void setEffects(@NonNull List<@NonNull Effect> effects)
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.