Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Stop does not complete when called immediately after startStream #435

Open
Goolpe opened this issue Nov 15, 2024 · 0 comments
Open

Comments

@Goolpe
Copy link

Goolpe commented Nov 15, 2024

Package version

  • record: ^5.2.0 (tried with 5.1.2 - same problem)

Environment

  • OS: Android
  • Device: Emulator android-arm64 Pixel 4 API 34 / Samsung A54 / Xiaomi 12T

Describe the bug

We need to have opportunity to stop the recorder immediately after the start.
iOS works fine, but android has the problem with it.
If we try to stop immediately after startStream - stop does not complete
Tried to add 50ms delay before the stop, but it doesn't work for all devices.
This issue seems very similar, but fix didn't help

To Reproduce

Steps to reproduce the behavior:

  1. Run the project with this code
void main() {
  runApp(_App());
}

class _App extends StatelessWidget {
  const _App({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: _TestRecorder(),
    );
  }
}

class _TestRecorder extends StatefulWidget {
  const _TestRecorder({super.key});

  @override
  State<_TestRecorder> createState() => _TestRecorderState();
}

class _TestRecorderState extends State<_TestRecorder> {
  final _recorder = AudioRecorder();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ElevatedButton(
          onPressed: () async {
            print('START');
            await _recorder.startStream(const RecordConfig(
              encoder: AudioEncoder.pcm16bits,
              sampleRate: 16000,
              numChannels: 1,
              noiseSuppress: true,
              androidConfig: AndroidRecordConfig(manageBluetooth: false),
            ));

            print('START FINISHED');

            await _recorder.stop();

            print('STOP FINISHED');
          },
          child: const Text('TEST'),
        ),
      ),
    );
  }
}
  1. Tap 'test' button
  2. 'STOP FINISHED' doesn't appear

Expected behavior

Should stop like in iOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant