esysberlin / esys-flutter-share

A Flutter plugin for sharing files & text with other applications.
Apache License 2.0
130 stars 147 forks source link

Can't share audio #68

Open FilipeOS opened 4 years ago

FilipeOS commented 4 years ago

Hi there,

I'm developing an app (for myself and testing) that I'm able to record sound from mic and save it on a List<Uint8List> (using sound_stream plugin) and I think I'm doing something wrong.

To play all in list I do this:

void _play() async {
    await _player.start();

    if (_micChunks.isNotEmpty) {
      for (var chunk in _micChunks) {
        await _player.writeChunk(chunk);
      }
      //_micChunks.clear();
      _isPlaying = false;
    }
  }

And to share I'm trying to do this (share ONLY the last on list):

void _save() async {
    try {
      await Share.file(
          'Sound', 'custom_sound.mp3', _micChunks.last.buffer.asUint8List(), 'audio/*');
    } catch (e) {
      print('error: $e');
    }
  }

Any advise please? Thank you!