How to control a camera and microphone with GoCoder SDK for Android

Learn how to use the WZCamera class and WowzaGoCoder classes in the Wowza GoCoder™ SDK for Android to control cameras and microphones on a device.


Control a camera Control a microphone

Control a camera

Use the WZCamera class to control camera capabilities that may vary from one camera to another.

Note: Most camera configuration options that don't vary by camera are controlled by the WZCameraView class.

Determine camera capabilities

The WZCamera class uses the following methods to determine the capabilities supported by a particular camera.

getSupportedFrameSizes() Returns an array of the frame sizes supported by the camera.
hasCapability(WZCamera.TORCH) Returns true if a camera has an associated flashlight (torch).
hasCapability(WZCamera.FOCUS_MODE_AUTO) Returns true if the camera supports auto-focusing to a specified point location.
hasCapability(WZCamera.FOCUS_MODE_CONTINUOUS) Returns true if the camera supports continuously adjusting the focus.

The following example configures the WZCamera.TORCH method:

// Enable the torch button if the current camera has a flashlight (aka torch)
WZCamera activeCamera = this.goCoderCameraView.getCamera();

Turn on a camera flashlight

Use the isTorchOn and setTorchOn methods, respectively, to determine the state of the camera's flashlight and to turn it on and off.

// Turn the torch on if it is not already enabled
WZCamera activeCamera = this.goCoderCameraView.getCamera();
if (!activeCamera.isTorchOn())

Control a microphone

Use the muteAudio method of the WowzaGoCoder class to mute or pause audio while streaming.

// Mute the audio stream if it isn't already
if (!this.goCoder.isMuted())
  this.goCoder.muteAudio = newMutedState;

If you're having problems or want to discuss this article, post in our forum.