Skip to content

Flashlight management while publishing video from main camera

Since build 1.1.0.17 it is possible to turn on and off flashlight while publishiung video from main device camera.

To turn flashlight on, use the function Flashphoner.turnOnFlashlight()

code

private void turnOnFlashlight() {
    if (Flashphoner.turnOnFlashlight()) {
        mSwitchFlashlightButton.setText(getResources().getString(R.string.turn_off_flashlight));
        flashlight = true;
    }
}

To turn flashlight off, use the function Flashphoner.turnOffFlashlight()

code

private void turnOffFlashlight() {
    Flashphoner.turnOffFlashlight();
    mSwitchFlashlightButton.setText(getResources().getString(R.string.turn_on_flashlight));
    flashlight = false;
}

These functions may be called by keypress, for example

code

mSwitchFlashlightButton.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        if (flashlight) {
            turnOffFlashlight();
        } else {
            turnOnFlashlight();
        }
    }
});