Class DefaultAudioRecordingService
java.lang.Object
com.gluonhq.attach.audiorecording.impl.DefaultAudioRecordingService
- All Implemented Interfaces:
AudioRecordingService
- Direct Known Subclasses:
DesktopAudioRecordingService
,IOSAudioRecordingService
-
Property Summary
TypePropertyDescriptionjavafx.beans.property.ReadOnlyBooleanProperty
Returnstrue
when the audio recording is currently active andfalse
if audio recording is stopped. -
Field Summary
Fields inherited from interface com.gluonhq.attach.audiorecording.AudioRecordingService
DEFAULT_EXTERNAL_FOLDER
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Removes the content of the audio folder.javafx.beans.property.ReadOnlyListProperty<String>
Returns a read only observable list of file names.Returns the folder where all the audio files will be storedjavafx.beans.property.ReadOnlyBooleanProperty
Returnstrue
when the audio recording is currently active andfalse
if audio recording is stopped.void
setAudioFolderName
(String folderName) Sets the name of the external folder where the audio files will be saved.protected abstract void
start
(float sampleRate, int sampleSizeInBits, int channels, int chunkRecordTime, Function<String, Boolean> addChunk) void
startRecording
(float sampleRate, int sampleSizeInBits, int channels, int chunkRecordTime) Start audio recording with the given parameters.protected abstract void
stop()
void
Stop audio recording.protected static void
updateRecordingStatus
(boolean recording)
-
Property Details
-
recording
public javafx.beans.property.ReadOnlyBooleanProperty recordingProperty- Specified by:
recordingProperty
in interfaceAudioRecordingService
-
-
Constructor Details
-
DefaultAudioRecordingService
public DefaultAudioRecordingService()
-
-
Method Details
-
startRecording
public void startRecording(float sampleRate, int sampleSizeInBits, int channels, int chunkRecordTime) Description copied from interface:AudioRecordingService
Start audio recording with the given parameters. The recorded audio files are saved in wav format in chunks of the specified recording time.- Specified by:
startRecording
in interfaceAudioRecordingService
- Parameters:
sampleRate
- the number of samples per second (8000.0f, 44100.0f, ...)sampleSizeInBits
- the number of bits in each sample (16 or 8)channels
- the number of channels (1 for mono, 2 for stereo)chunkRecordTime
- the duration in seconds of each chunk (60, 360, ...)
-
stopRecording
public void stopRecording()Description copied from interface:AudioRecordingService
Stop audio recording.- Specified by:
stopRecording
in interfaceAudioRecordingService
-
recordingProperty
public javafx.beans.property.ReadOnlyBooleanProperty recordingProperty()Description copied from interface:AudioRecordingService
Returnstrue
when the audio recording is currently active andfalse
if audio recording is stopped.- Specified by:
recordingProperty
in interfaceAudioRecordingService
-
setAudioFolderName
Description copied from interface:AudioRecordingService
Sets the name of the external folder where the audio files will be saved. If not set, by default it will useAudioRecordingService.DEFAULT_EXTERNAL_FOLDER
.- Specified by:
setAudioFolderName
in interfaceAudioRecordingService
- Parameters:
folderName
- the name of the external folder where the audio files will be saved
-
getAudioFolder
Description copied from interface:AudioRecordingService
Returns the folder where all the audio files will be stored- Specified by:
getAudioFolder
in interfaceAudioRecordingService
- Returns:
- a File with the audio folder
-
clearAudioFolder
public void clearAudioFolder()Description copied from interface:AudioRecordingService
Removes the content of the audio folder.This method can be called at any time. It is convenient to call it before the audio recording starts, or when it ends and the audio files have been safely extracted.
- Specified by:
clearAudioFolder
in interfaceAudioRecordingService
-
getAudioChunkFiles
Description copied from interface:AudioRecordingService
Returns a read only observable list of file names. It contains a list of file chunks that are saved in theaudio folder
. It can be used during recording to track when new audio chunks are made available in the audio folder.- Specified by:
getAudioChunkFiles
in interfaceAudioRecordingService
- Returns:
- A
ReadOnlyListProperty
of file names
-
start
-
stop
protected abstract void stop() -
updateRecordingStatus
protected static void updateRecordingStatus(boolean recording)
-