Class DefaultStreamMediaRecorder
-
- All Implemented Interfaces:
-
io.getstream.sdk.chat.audio.recording.StreamMediaRecorder
public final class DefaultStreamMediaRecorder implements StreamMediaRecorder
The default implementation of StreamMediaRecorder, used as a wrapper around MediaRecorder simplifying working with it.
-
-
Constructor Summary
Constructors Constructor Description DefaultStreamMediaRecorder(Context context)
-
Method Summary
-
-
Method Detail
-
startAudioRecording
Result<File> startAudioRecording(String recordingName, Long amplitudePollingInterval, Boolean override)
Creates a File internally and starts recording. Calling the function again after a recording has already been started will reset the recording process.
- Parameters:
recordingName- The file name the recording will be stored under.amplitudePollingInterval- Dictates how often the recorder is polled for the latest max amplitude and how often onMaxAmplitudeSampledListener emits a new value.override- Determines if the new recording file should override one with the same name, if it exists.- Returns:
The File to which the recording will be stored wrapped inside a Result if recording has started successfully. Returns a Error wrapped inside a Result if the action had failed.
-
startAudioRecording
Result<Unit> startAudioRecording(File recordingFile, Long amplitudePollingInterval)
Prepares the given recordingFile and starts recording. Calling the function again after a recording has already been started will reset the recording process.
- Parameters:
recordingFile- The File the audio will be saved to once the recording stops.amplitudePollingInterval- Dictates how often the recorder is polled for the latest max amplitude and how often onMaxAmplitudeSampledListener emits a new value.- Returns:
A Unit wrapped inside a Result if recording has started successfully. Returns a ChatError wrapped inside Result if the action had failed.
-
stopRecording
Result<RecordedMedia> stopRecording()
Stops recording and saves the recording to the file provided by startAudioRecording.
- Returns:
A Unit wrapped inside a Result if recording has been stopped successfully. Returns a ChatError wrapped inside Result if the action had failed.
-
deleteRecording
Result<Unit> deleteRecording(File recordingFile)
Deleted the recording to the file provided by recordingFile.
- Parameters:
recordingFile- The File to be deleted.- Returns:
A Unit wrapped inside a Result if recording has been deleted successfully. Returns a ChatError wrapped inside Result if the action had failed.
-
release
Unit release()
Releases the MediaRecorder used by StreamMediaRecorder.
-
setOnErrorListener
Unit setOnErrorListener(StreamMediaRecorder.OnErrorListener onErrorListener)
Sets an error listener.
- Parameters:
onErrorListener- StreamMediaRecorder.OnErrorListener SAM used to notify the user about any underlying MediaRecorder errors.
-
setOnInfoListener
Unit setOnInfoListener(StreamMediaRecorder.OnInfoListener onInfoListener)
Sets an info listener.
- Parameters:
onInfoListener- StreamMediaRecorder.OnInfoListener SAM used to notify the user about any underlying MediaRecorder information events.
-
setOnRecordingStartedListener
Unit setOnRecordingStartedListener(StreamMediaRecorder.OnRecordingStarted onRecordingStarted)
Sets an StreamMediaRecorder.OnRecordingStarted listener on this instance of StreamMediaRecorder.
- Parameters:
onRecordingStarted- StreamMediaRecorder.OnRecordingStarted SAM used for notifying after the recording has started successfully.
-
setOnRecordingStoppedListener
Unit setOnRecordingStoppedListener(StreamMediaRecorder.OnRecordingStopped onRecordingStopped)
Sets an StreamMediaRecorder.OnRecordingStopped listener on this instance of StreamMediaRecorder.
- Parameters:
onRecordingStopped- StreamMediaRecorder.OnRecordingStarted SAM used to notify the user after the recording has stopped.
-
setOnMaxAmplitudeSampledListener
Unit setOnMaxAmplitudeSampledListener(StreamMediaRecorder.OnMaxAmplitudeSampled onMaxAmplitudeSampled)
Sets a StreamMediaRecorder.setOnMaxAmplitudeSampledListener listener on this instance of StreamMediaRecorder.
- Parameters:
onMaxAmplitudeSampled- StreamMediaRecorder.setOnMaxAmplitudeSampledListener SAM used to notify when a new maximum amplitude value has been sampled.
-
setOnMediaRecorderStateChangedListener
Unit setOnMediaRecorderStateChangedListener(StreamMediaRecorder.OnMediaRecorderStateChange onMediaRecorderStateChange)
Sets a StreamMediaRecorder.OnMediaRecorderStateChange listener on this instance of StreamMediaRecorder.
- Parameters:
onMediaRecorderStateChange- StreamMediaRecorder.OnMediaRecorderStateChange SAM used to notify when the media recorder state has changed.
-
setOnCurrentRecordingDurationChangedListener
Unit setOnCurrentRecordingDurationChangedListener(StreamMediaRecorder.OnCurrentRecordingDurationChanged onCurrentRecordingDurationChanged)
Sets a StreamMediaRecorder.OnCurrentRecordingDurationChanged listener on this instance of StreamMediaRecorder.
- Parameters:
onCurrentRecordingDurationChanged- StreamMediaRecorder.OnCurrentRecordingDurationChanged SAM updated when the duration of the currently active recording has changed.
-
-
-
-