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

Recording data in safari #382

Closed
dhiren8391 opened this issue Aug 18, 2024 · 2 comments
Closed

Recording data in safari #382

dhiren8391 opened this issue Aug 18, 2024 · 2 comments

Comments

@dhiren8391
Copy link

dhiren8391 commented Aug 18, 2024

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
Copy link
Owner

I suggest you to use cross_file package for this.

This should be easy as:

final path = await recorder.stop();
final file = XFile(path);
final bytes = await file.readAsBytes();

@dhiren8391
Copy link
Author

Issue not resolved
@llfbandit this solution does not work. I got 44 byte in bytes.

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