audio_streamer 2.0.0 copy "audio_streamer: ^2.0.0" to clipboard
audio_streamer: ^2.0.0 copied to clipboard

outdated

Streaming of Pulse-code modulation (PCM) audio from Android and iOS

audio_streamer #

Streaming of PCM audio from Android and iOS with a sample rate of 44,100 Hz

Permissions #

On Android you need to add a permission to AndroidManifest.xml:

<uses-permission android:name="android.permission.RECORD_AUDIO" />

On iOS enable the following:

  • Capabilities > Background Modes > Audio, AirPlay and Picture in Picture
  • In the Runner Xcode project edit the Info.plist file. Add an entry for 'Privacy - Microphone Usage Description'

When editing the Info.plist file manually, the entries needed are:

<key>NSMicrophoneUsageDescription</key>
<string>YOUR DESCRIPTION</string>
<key>UIBackgroundModes</key>
<array>
  <string>audio</string>
</array>

Example Usage #

See the file example/lib/main.dart for a fully fledged example app using the plugin.

  AudioStreamer _streamer = AudioStreamer();
  bool _isRecording = false;
  List<double> _audio = [];
  
  void onAudio(List<double> buffer) {
    _audio.addAll(buffer);
    double secondsRecorded = _audio.length.toDouble() / _streamer.sampleRate.toDouble();
    print('$secondsRecorded seconds recorded.');
  }

  void start() async {
    try {
      _streamer.start(onAudio);
      setState(() {
        _isRecording = true;
      });
    } catch (error) {
      print(error);
    }
  }

  void stop() async {
    bool stopped = await _streamer.stop();
    setState(() {
      _isRecording = stopped;
    });
  }
37
likes
0
pub points
88%
popularity

Publisher

verified publishercachet.dk

Streaming of Pulse-code modulation (PCM) audio from Android and iOS

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, permission_handler

More

Packages that depend on audio_streamer