open method
Open a Recorder
A recorder must be opened before used. A recorder correspond to an Audio Session. With other words, you must open the Audio Session before using it.
When you have finished with a Recorder, you must close it. With other words, you must close your Audio Session.
Opening a recorder takes resources inside the OS. Those resources are freed with the verb closeAudioSession()
.
You MUST ensure that the recorder has been closed when your widget is detached from the UI.
Overload your widget's dispose()
method to close the recorder when your widget is disposed.
In this way you will reset the Recorder and clean up the device resources, but the recorder will be no longer usable.
@override
void dispose()
{
if (myRecorder != null)
{
myRecorder.closeAudioSession();
myRecorder = null;
}
super.dispose();
}
You may not openAudioSession many recorders without releasing them.
openAudioSession()
and closeAudioSession()
return Futures.
You do not need to wait the end of the initialization before startRecorder()
.
startRecorder
will automaticaly wait the end of openAudioSession()
before starting the recorder.
The four optional parameters are used if you want to control the Audio Focus. Please look to TauRecorder openAudioSession() to understand the meaning of those parameters
Example:
myRecorder = await TauRecorder().openAudioSession();
...
(do something with myRecorder)
...
myRecorder.closeAudioSession();
myRecorder = null;
Implementation
Future<TauRecorder?> open({
required InputDeviceNode from,
required OutputNode to,
}) async {
if (_isInited) {
return this;
}
TauRecorder? r;
_logger.d('FS:---> open ');
await _lock.synchronized(() async {
r = await _open(from: from, to: to);
});
_logger.d('FS:<--- open ');
return r;
}