Class DefaultAudioRecordingService
- java.lang.Object
-
- com.gluonhq.attach.audiorecording.impl.DefaultAudioRecordingService
-
- All Implemented Interfaces:
AudioRecordingService
- Direct Known Subclasses:
DesktopAudioRecordingService
,IOSAudioRecordingService
public abstract class DefaultAudioRecordingService extends java.lang.Object implements AudioRecordingService
-
-
Field Summary
-
Fields inherited from interface com.gluonhq.attach.audiorecording.AudioRecordingService
DEFAULT_EXTERNAL_FOLDER
-
-
Constructor Summary
Constructors Constructor Description DefaultAudioRecordingService()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
clearAudioFolder()
Removes the content of the audio folder.javafx.beans.property.ReadOnlyListProperty<java.lang.String>
getAudioChunkFiles()
Returns a read only observable list of file names.java.io.File
getAudioFolder()
Returns the folder where all the audio files will be storedjavafx.beans.property.ReadOnlyBooleanProperty
recordingProperty()
Returnstrue
when the audio recording is currently active andfalse
if audio recording is stopped.void
setAudioFolderName(java.lang.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, java.util.function.Function<java.lang.String,java.lang.Boolean> addChunk)
void
startRecording(float sampleRate, int sampleSizeInBits, int channels, int chunkRecordTime)
Start audio recording with the given parameters.protected abstract void
stop()
void
stopRecording()
Stop audio recording.protected static void
updateRecordingStatus(boolean recording)
-
-
-
Method Detail
-
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
- Returns:
- a read only boolean property with the recording status
-
setAudioFolderName
public void setAudioFolderName(java.lang.String folderName)
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
public java.io.File 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
public javafx.beans.property.ReadOnlyListProperty<java.lang.String> 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
protected abstract void start(float sampleRate, int sampleSizeInBits, int channels, int chunkRecordTime, java.util.function.Function<java.lang.String,java.lang.Boolean> addChunk)
-
stop
protected abstract void stop()
-
updateRecordingStatus
protected static void updateRecordingStatus(boolean recording)
-
-