Closed tonypottera24 closed 3 years ago
I have not tested the code you gave, but I had a similar problem.
When you try sound playback after recording, _channel.setMethodCallHandler
called with some playback callback (like updateProgress
).
However, _setRecorderCallback
handles callbacks only updateRecorderProgress
and updateDbPeakProgress
, in addition, it throws the error to other callbacks.
Future<void> _setRecorderCallback() async {
if (_recorderController == null) {
_recorderController = new StreamController.broadcast();
}
if (_dbPeakController == null) {
_dbPeakController = new StreamController.broadcast();
}
_channel.setMethodCallHandler((MethodCall call) {
switch (call.method) {
case "updateRecorderProgress":
Map<String, dynamic> result = json.decode(call.arguments);
if (_recorderController != null)
_recorderController.add(new RecordStatus.fromJSON(result));
break;
case "updateDbPeakProgress":
if (_dbPeakController!= null)
_dbPeakController.add(call.arguments);
break;
default:
throw new ArgumentError('Unknown method ${call.method} ');
}
return null;
});
}
It looks like playback callback makes problem, but actually it caused by the recorder callback handler. (I was so complicated...:anguished:)
I got this problem in version 2.1.1, but I found _setRecorderCallback
is modified on latest commit.
Why don't you give it a try if you are using older version?
@kiha-la Thank you for your advice, but the problem still exists in flutter_sound: ^3.0.0
This issue is fixed in 3.1.1
.
But currently, onRecorderDbPeakChanged
is not responding on resumeRecorder
.
I do not see any problem on iOS flutter_sound release 3.1.0
I'm using Samsung Galaxy S8, Android 9
move to #282
This problem happens again on flutter_sound: ^6.1.4
.
_flutterSoundRecorder.onProgress.listen(_recorderProgressChanged)
stops responding after startPlayer
is called from another audioSession.
I found out that given a FlutterSoundRecorder
and a FlutterSoundPlayer
.
If their category are set to SessionCategory.record
and SessionCategory.playback
accordingly.
On iPhone 6 Plus and iPhone 8 Plus, they will collide with each other.
When FlutterSoundRecorder is recording, calling FlutterSoundPlayer can raise an exception and stop the recording.
However, this situation doesn't happen on iPhone simulators and Android devices (Samsung Galaxy s8).
If we omit the SessionCategory setting (default is SessionCategory.playAndRecord), it works well on iPhone real devices. @Larpoux do you think this is a bug?
Yes Tony, you are right. The big problem is that on iOS there is just one audio-session for each App. It means that I have big problems to support Flutter Sound which allows several Audio Sessions simultaneously.
Actually it does not work very correctly, because the last open-session override the previous ones. I know that I will have to work to do something better than now, (or someone else 🙄 ). But not simple because of the limitations of iOS
Do you know why (sorry, just curious) when recording video, flutter_sound cannot record audio (I want to use voice meter) at the same time on Android, but this is possible on iOS?
Sorry, I do not know. I never tried, and I am definitely not an audio expert on ios or Android.
Please open new issues if still problems. This issue mixes several different points and so, cannot be identified as a TODO task.
Version of flutter_sound
flutter_sound: ^2.1.1
andflutter_sound: ^3.0.0
flutter doctor
Platforms you faced the error (IOS or Android or both?)
iOS
Expected behavior
onRecorderDbPeakChanged should keep returning values.
Actual behavior
onRecorderDbPeakChanged stops responding.
Tested environment (Emulator? Real Device?)
iOS 13.3 emulator
Steps to reproduce the behavior