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

[iOS] No Audio Input When Streaming Through Headphones #451

Open
Goolpe opened this issue Dec 13, 2024 · 4 comments
Open

[iOS] No Audio Input When Streaming Through Headphones #451

Goolpe opened this issue Dec 13, 2024 · 4 comments

Comments

@Goolpe
Copy link

Goolpe commented Dec 13, 2024

Package version
^5.2.0

Environment

  • OS: iOS
  • Tested on airpods 3 and pro 2, iPhone 11

Describe the bug

When recording audio through headphones, no sound is produced. Instead, the following data is received:
[0, 8, 254, 232, 68, 0, 0, 0, 0, 0, 0, 0, ... zeros ..., 0].

To Reproduce

Steps to reproduce the behavior:

  1. Copy and paste the code
  2. Run the app on iOS
  3. Connect headphones (airpods)
  4. Press start and try to say something
  5. Press stop
  6. Disconnect headphones and try again
import 'package:flutter/material.dart';
import 'package:record/record.dart';

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: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () async {
                final stream = await _recorder
                    .startStream(const RecordConfig(encoder: AudioEncoder.pcm16bits));

                stream.listen((data) {
                  print('DATA: ${data.buffer.asUint8List()}');
                });
              },
              child: const Text('START'),
            ),
            ElevatedButton(
              onPressed: () async {
                await _recorder.stop();
              },
              child: const Text('STOP'),
            ),
          ],
        ),
      ),
    );
  }
}

Expected behavior

Audio should be recorded through the connected headphones.

@llfbandit
Copy link
Owner

Thanks for reporting.
This issue is unclear to me. Do you mean that the first try works and not the subsequent tries?

@Goolpe
Copy link
Author

Goolpe commented Dec 23, 2024

No, it never works...
It always returns the same list [0, 8, 254, 232, 68, 0, 0, 0, 0, 0, 0, 0, ... zeros ..., 0]

@llfbandit
Copy link
Owner

Does it work with file recording?

@Goolpe
Copy link
Author

Goolpe commented Dec 23, 2024

Hm, interesting, it works now with startStream,
But it's strange, some users sent us feedback that airpods didn't work in our app on ios
I tested and it worked at that moment, but after some days,
I tried it again in app and with this example (in issue) without any other packages, and it didn't work.
But now it works...
Could some other apps / configurations affect?

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

2 participants