Closed tonypottera24 closed 4 years ago
+1
Also looking for the feature
@tonypottera24 , @konstantin-mohin : Beta 3.1.1 offers 2 new API verbs :
Until it will be integrated, it would be great in the meantime if you can test it.
If you are still with flutter_sound 2.x.x compatibility :
flutter_sound.startRecorder(.....);
flutter_sound.pauseRecorder();
flutter_sound.resumeRecorder();
flutter_sound.stopRecorder();
Oh! I forgot to give you the link : https://github.com/Canardoux/flauto . (#257)
Thank you for your help. But I'm little bit confused about the new design. Should it follow the life cycle? initialize() -> startRecorder() -> pauseRecorder() -> resumeRecorder() -> stopRecorder()
Yes, this is the correct cycle. In fact there is no major changes from version 2.1.0. If you use the compatibility module "FlutterSound", you do not have to change your code. Just use the verbs pauseRecorder() and resumeRecorder() after starting your recorder, and before you call stopRecorder().
The new API will use a new object : FlutterSoundRecorder
instead of FlutterSound.
Using it is very similar to the legacy FlutterSound
.
The major difference is that you must call FlutterSoundRecorder.initialize()
before using it, and call FlutterSoundRecorder
when you have finished with it.
Note : in the current beta version the new module is called FlautoRecorder
but I am going to change this name to FlutterSoundRecorder
today.
It works on Android.
Currently I found few issues.
isRecording()
, isPaused()
, isStopped()
should use get
to make them looks like isRecording
, isPaused
, isStopped
.isRecording()
maybe should remain true during the whole recording progress even when isPaused()
.flautoPlayer.startPlayerFromBuffer
failed during recording. This operation will damage the DB meter callback, but can play sounds in previous version.@tonypottera24 : thank you very much to spent some of your time to test the beta version.
get
for isRecording, isPaused, and isStopped.3.
flautoPlayer.startPlayerFromBuffer
failed during recording. This operation will damage the DB meter callback, but can play sounds in previous version.
Which OS : iOS or Android ?
@Larpoux How I can use Beta 3.1.1? flutter pub get failed to get plugin. And i'm currently using 2.1.1 version but i not able to access this methods flutter_sound.pauseRecorder(); flutter_sound.resumeRecorder();
Please give me solution. Thank you.
Beta 3.1.x is not actually merged in flutter_sound Master branch. It means that if you want to test this beta version, you must use the beta-branch
@tonypottera24 : I fixed some conflicts in temporary files when several FlutterSoundRecorder and several FlutterSoundPlayer. Could you check the beta-branch ? Thank you.
@Larpoux
When will this branch get merge in master. can you give me tentative days.
This is an excellent plugin for recording.
Thank you @anup-geeky for your compliments. The beta version has deep modifications. The architecture has been redesigned. So we need intensive tests. But I hope that this version will be released very soon. @hyochan ?
Thank you for your help. I'm testing on Galaxy S8 it still doesn't play sounds, but everytime I try to play, it gives following logs
D/FlutterSoundPlugin(11953): rawAmplitude: 1958.0 Base DB: 45.52813080965572
D/FlutterSoundPlugin(11953): rawAmplitude: 2224.0 Base DB: 46.634572718513745
D/ViewRootImpl@d13bfcf[MainActivity](11953): ViewPostIme pointer 0
D/ViewRootImpl@d13bfcf[MainActivity](11953): ViewPostIme pointer 1
V/MediaPlayer-JNI(11953): native_setup
V/MediaPlayerNative(11953): constructor
V/MediaPlayerNative(11953): setListener
V/MediaPlayer-JNI(11953): setDataSourceFD: fd 105
V/MediaPlayerNative(11953): setDataSource(105, 0, 576460752303423487)
V/MediaPlayerNative(11953): setVideoSurfaceTexture
V/MediaPlayerNative(11953): prepare
V/MediaPlayerNative(11953): message received msg=200, ext1=10973, ext2=0
W/MediaPlayerNative(11953): info/warning (10973, 0)
V/MediaPlayerNative(11953): callback application
V/MediaPlayerNative(11953): back from callback
V/MediaPlayerNative(11953): message received msg=1, ext1=0, ext2=0
V/MediaPlayerNative(11953): MediaPlayer::notify() prepared
V/MediaPlayerNative(11953): signal application thread
V/MediaPlayerNative(11953): callback application
V/MediaPlayerNative(11953): prepare complete - status=0
V/MediaPlayerNative(11953): back from callback
V/MediaPlayerNative(11953): invoke 68
V/MediaPlayerNative(11953): invoke 68
D/FlutterSoundPlugin(11953): mediaPlayer prepared and start
V/MediaPlayer-JNI(11953): start
V/MediaPlayerNative(11953): start
V/MediaPlayerNative(11953): getDuration_l
V/MediaPlayer-JNI(11953): getDuration: 572 (msec)
V/MediaPlayer-JNI(11953): getCurrentPosition: 0 (msec)
I/flutter (11953): startPlayer result: .../flutter_sound1789336971910600526.aac
V/MediaPlayerNative(11953): getDuration_l
V/MediaPlayer-JNI(11953): getDuration: 572 (msec)
V/MediaPlayer-JNI(11953): getCurrentPosition: 0 (msec)
V/MediaPlayer-JNI(11953): stop
V/MediaPlayerNative(11953): stop
V/MediaPlayerNative(11953): message received msg=8, ext1=0, ext2=0
V/MediaPlayerNative(11953): unrecognized message: (8, 0, 0)
V/MediaPlayerNative(11953): callback application
V/MediaPlayerNative(11953): back from callback
V/MediaPlayer-JNI(11953): reset
V/MediaPlayerNative(11953): reset
V/MediaPlayer(11953): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(11953): cleanDrmObj: mDrmObj=null mDrmSessionId=null
V/MediaPlayer(11953): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(11953): cleanDrmObj: mDrmObj=null mDrmSessionId=null
V/MediaPlayer-JNI(11953): release
V/MediaPlayerNative(11953): setListener
V/MediaPlayerNative(11953): disconnect
V/MediaPlayerNative(11953): destructor
V/MediaPlayerNative(11953): disconnect
D/FlutterSoundPlugin(11953): rawAmplitude: 1754.0 Base DB: 44.572468840913785
D/FlutterSoundPlugin(11953): rawAmplitude: 2551.0 Base DB: 47.82608623250915
D/FlutterSoundPlugin(11953): rawAmplitude: 2736.0 Base DB: 48.43419892127492
D/FlutterSoundPlugin(11953): rawAmplitude: 2244.0 Base DB: 46.712334111995816
Hope this will help.
I just did a last test on my Xiaomi and my Huawei and I do not encounter any problems in playback.
V/MediaPlayer-JNI(11953): getDuration: 572 (msec)
Your record seems very short!
Are you root on your Smartphone ? if yes, you could check the file .../flutter_sound1789336971910600526.aac
.
0.5 seconds is really short !
it is a "ring" or "ding" sound effect, it has to be short.
Which module do you use ? FlutterSoundPlayer ? or TrackPlayer ? (probably FlutterSoundPlayer if this is sound effects ...)
Are you sure to called myModule.initializePlayer()
?
This is what I do not like :
V/MediaPlayerNative(11953): message received msg=8, ext1=0, ext2=0
V/MediaPlayerNative(11953): unrecognized message: (8, 0, 0)
Which Android on your smartphone ? Which is your Target AndroidSdkVersion of your App ?
If you want to send me your code, I can check on my side. (I have a few hours free this after-noon. This is something not frequent 😆 .
Android 9.0 targetSdkVersion 28
class RingController {
Uint8List _alarmSoundBuffer;
FlautoPlayer _flautoPlayer = FlautoPlayer();
Future<void> init() async {
_alarmSoundBuffer = (await rootBundle.load('assets/audio/desk_bell.m4a'))
.buffer
.asUint8List();
}
Future<void> ring([int n = 1]) async {
await _flautoPlayer.initialize();
if (_alarmSoundBuffer != null) {
for (int i = 0; i < n; i++) {
await _flautoPlayer.startPlayerFromBuffer(_alarmSoundBuffer);
if (i < n - 1) {
await Future.delayed(const Duration(milliseconds: 300));
}
}
}
await _flautoPlayer.release();
}
}
At first seeing your code seems OK. Two remarks :
FlutterSoundPlayer
and FlutterSoundRecorder
and not the beta FlautoPlayer
and FlautoRecorder
init
function and not Release it each time the User has a 'Bip'.But this does not explain your problem...
It works on the beta branch! Sorry that I made some mistakes in pubspec.yaml settings. I'll try 3.1.0 soon.
That's fine. I like when things works without needed to fix bugs 😆
But be sure that files xxx.m4a is OK for FlutterSound on Android. I am not sure that .m4a is compatible with flutter_sound AAC
Thank you for your notice, I'll look into it.
I found that in 3.1.1
, onRecorderDbPeakChanged
will not crash on startPlayer
now, but it will pause on pauseRecorder()
(as expected) and stop responding after resumeRecorder()
(not expected).
Another issue is setDbLevelEnabled
, updateDbPeakProgress
and onRecorderDbPeakChanged
seems be forgot in the README.
Documentation is (as always) a big problem. My feeling is that I must rewrite all the thing. But I prefer (as every body) to code and not to document. Specially in English which is not easy for me.
haha, English is not my mother language too...
Some little advice:
FlutterSound
is now separate into FlutterSoundPlayer
and FlutterSoundRecorder
, so the function name such as startPlayer
, startPlayerFromBuffer
can be changed to start
and startFromBuffer
now.
Also, in convention, I think whenFinished
should be onFinished
.
You are certainly right. But too late ... 3.1.0 is released now. 😄
Please be free to re-open this issue, if you think it has not been solved correctly
Version of flutter_sound
flutter_sound: ^2.1.1
I'm wondering if there's any way to pause / resume the audio recording.