public class MediaRecorderBuilder

  1. Object
  2. MediaRecorderBuilder
A builder class to generate a Media recorder with specific settings.

Constructors

public MediaRecorderBuilder()

Methods

public MediaRecorderBuilder audioChannels(int numChannels)Set the number of audio channels in the media recorder.
public MediaRecorderBuilder bitRate(int bitRate)Sets the bit rate for the recorder.
public MediaRecorderBuilder samplingRate(int samplingRate)Sets the sampling rate for the recorder.
public MediaRecorderBuilder mimeType(String mimeType)Sets the mimetype to use for encoding the audio file.
public MediaRecorderBuilder path(String path)Sets the output path where the audio recording should be saved.
public MediaRecorderBuilder redirectToAudioBuffer(boolean redirect)Set this flag to true to redirect the microphone input to an audio buffer.
public Media build() throws IOExceptionBuilds the MediaRecorder with the given settings.
public int getAudioChannels()Gets the current audio channels settings.
public int getBitRate()Gets the current bit rate.
public int getSamplingRate()Gets the current sampling rate.
public String getMimeType()Gets the current mimetype.
public String getPath()Gets the current output path.
public boolean isRedirectToAudioBuffer()True if the media recorder should redirect output to an audio buffer instead of a file.

Inherited methods

Constructor details

MediaRecorderBuilder

public MediaRecorderBuilder()

Method details

audioChannels

public MediaRecorderBuilder audioChannels(int numChannels)
Set the number of audio channels in the media recorder. Default 1.

Parameters

numChannels int
The number of audio channels in the media recorder.

Returns

Self for chaining

bitRate

public MediaRecorderBuilder bitRate(int bitRate)
Sets the bit rate for the recorder. Default 64000.

Parameters

bitRate int
The bit rate for the recorder.

Returns

Self for chaining.

samplingRate

public MediaRecorderBuilder samplingRate(int samplingRate)
Sets the sampling rate for the recorder. Default 44100

Parameters

samplingRate int
The sample rate for the recorder.

Returns

Self for chaining.

mimeType

public MediaRecorderBuilder mimeType(String mimeType)
Sets the mimetype to use for encoding the audio file.

Parameters

mimeType String
The mimetype to use for encoding the audio file.

Returns

Self for chaining.

path

public MediaRecorderBuilder path(String path)
Sets the output path where the audio recording should be saved.

Parameters

path String
The output path where the recording should be saved as a com.codename1.io.FileSystemStorage path

Returns

Self for chaining.

redirectToAudioBuffer

public MediaRecorderBuilder redirectToAudioBuffer(boolean redirect)
Set this flag to true to redirect the microphone input to an audio buffer. This is handy if you just want to capture the raw PCM data from the microphone.

Parameters

redirect boolean
True to redirect output to an audio buffer. The #path(java.lang.String) parameter would then be used as the path to the audio buffer instead of the output file.

Returns

Self for chaining.

build

public Media build() throws IOException
Builds the MediaRecorder with the given settings.

Throws

IOException
IllegalStateException
If #path(java.lang.String) is not set.

getAudioChannels

public int getAudioChannels()
Gets the current audio channels settings.

Returns

the audioChannels

getBitRate

public int getBitRate()
Gets the current bit rate.

Returns

the bitRate

getSamplingRate

public int getSamplingRate()
Gets the current sampling rate.

Returns

the samplingRate

getMimeType

public String getMimeType()
Gets the current mimetype.

Returns

the mimeType

getPath

public String getPath()
Gets the current output path.

Returns

the path

isRedirectToAudioBuffer

public boolean isRedirectToAudioBuffer()
True if the media recorder should redirect output to an audio buffer instead of a file.