Interface StreamMediaRecorder
-
- All Implemented Interfaces:
public interface StreamMediaRecorderA media recording interface, designed to simplify using MediaRecorder.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceStreamMediaRecorder.OnInfoListenerA functional interface used for listening to info events dispatched by the MediaRecorder internally used by StreamMediaRecorder.
public interfaceStreamMediaRecorder.OnErrorListenerA functional interface used for listening to error events dispatched by the MediaRecorder internally used by StreamMediaRecorder.
public interfaceStreamMediaRecorder.OnRecordingStartedA functional interface used for notifying after the recording has started successfully.
public interfaceStreamMediaRecorder.OnRecordingStoppedA functional interface used for notifying after the recording has stopped.
public interfaceStreamMediaRecorder.OnMaxAmplitudeSampledA functional interface used for emitting max amplitude readings during recording.
public interfaceStreamMediaRecorder.OnMediaRecorderStateChangeA functional interface used for listening to StreamMediaRecorder state changes.
public interfaceStreamMediaRecorder.OnCurrentRecordingDurationChangedA functional interface used for listening to updated in the duration of the currently active recording.
-
Method Summary
-
-
Method Detail
-
startAudioRecording
abstract 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 OnMaxAmplitudeSampled 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 ChatError wrapped inside a Result if the action had failed.
-
startAudioRecording
abstract 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 OnMaxAmplitudeSampled 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
abstract 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
abstract 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
abstract Unit release()
Releases the MediaRecorder used by StreamMediaRecorder.
-
setOnErrorListener
abstract 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
abstract Unit setOnInfoListener(StreamMediaRecorder.OnInfoListener onInfoListener)
Sets an info listener.
- Parameters:
onInfoListener- StreamMediaRecorder.OnInfoListener SAM used to notify the user about any underlying MediaRecorder information and warnings.
-
setOnRecordingStartedListener
abstract Unit setOnRecordingStartedListener(StreamMediaRecorder.OnRecordingStarted onRecordingStarted)
Sets a StreamMediaRecorder.OnRecordingStarted listener on this instance of StreamMediaRecorder.
- Parameters:
onRecordingStarted- StreamMediaRecorder.OnRecordingStarted SAM used for notifying after the recording has started successfully.
-
setOnRecordingStoppedListener
abstract Unit setOnRecordingStoppedListener(StreamMediaRecorder.OnRecordingStopped onRecordingStopped)
Sets a StreamMediaRecorder.OnRecordingStopped listener on this instance of StreamMediaRecorder.
- Parameters:
onRecordingStopped- StreamMediaRecorder.OnRecordingStarted SAM used to notify the user after the recording has stopped.
-
setOnMaxAmplitudeSampledListener
abstract 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
abstract 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
abstract 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.
-
-
-
-