llfbandit / record

Audio recorder from microphone to a given file path. No external dependencies, MediaRecorder is used for Android an AVAudioRecorder for iOS.
https://pub.dev/packages/record
230 stars 189 forks source link

Recording data in safari #388

Closed dhiren8391 closed 2 weeks ago

dhiren8391 commented 2 weeks ago
final path = await recorder!.stop();
final data = await fetchAudioData(path);

I tried both below functions. Every time I get 44 bytes in data. How do we get recorded audio bytes to pass in API for Safari browser?

Future<Uint8List> fetchAudioData(String url) async {
  html.HttpRequest request =
      await html.HttpRequest.request(url, responseType: 'arraybuffer');

  return Uint8List.view(request.response);
  // return Uint8List(0);
}

Future<Uint8List> fetchAudioData1(String blobUrl) async {
  final response = await html.window.fetch(blobUrl);
  final blob = await response.blob();
  final reader = html.FileReader();

  final completer = Completer<Uint8List>();
  reader.onLoadEnd.listen((event) {
    completer.complete(reader.result as Uint8List);
  });
  reader.readAsArrayBuffer(blob);
  return completer.future;
}
llfbandit commented 2 weeks ago

Please fill a simple reproducer with your recording configuration. Also, does it work in Chrome or Firefox? You could also try to confirm with the example project.

I guess the 44 bytes could be translated to string to check if safari provides an error from this content.

llfbandit commented 2 weeks ago

Released in record_web 1.1.3 Given encoder was not honored.