flutter_audio_capture_v2 1.2.2 copy "flutter_audio_capture_v2: ^1.2.2" to clipboard
flutter_audio_capture_v2: ^1.2.2 copied to clipboard

Capture the audio buffer stream through microphone for iOS/Android.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter_audio_capture_v2/flutter_audio_capture_v2.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final FlutterAudioCapture _plugin = FlutterAudioCapture();

  @override
  void initState() {
    super.initState();
    // Need to initialize before use note that this is async!
    _plugin.init();
  }

  Future<void> _startCapture() async {
    await _plugin.start(listener, onError, sampleRate: 16000, bufferSize: 3000);
  }

  Future<void> _stopCapture() async {
    await _plugin.stop();
  }

  void listener(dynamic obj) {}

  void onError(Object e) {}

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Flutter Audio Capture Plugin'),
        ),
        body: Column(children: [
          Expanded(
              child: Row(
            children: [
              Expanded(child: Center(child: FloatingActionButton(onPressed: _startCapture, child: Text("Start")))),
              Expanded(child: Center(child: FloatingActionButton(onPressed: _stopCapture, child: Text("Stop")))),
            ],
          ))
        ]),
      ),
    );
  }
}
0
likes
130
points
28
downloads

Publisher

unverified uploader

Weekly Downloads

Capture the audio buffer stream through microphone for iOS/Android.

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_audio_capture_v2