internal_audio_recorder 0.1.2 internal_audio_recorder: ^0.1.2 copied to clipboard
A new Flutter plugin for android that record internal audio and output it as PCM file.
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:internal_audio_recorder/internal_audio_recorder.dart';
import 'package:internal_audio_recorder/model/audioformat.dart';
import 'package:path_provider/path_provider.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _internalAudioRecorderPlugin = InternalAudioRecorder();
@override
void initState() {
super.initState();
}
// Platform messages are asynchronous, so we initialize in an async method.
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
MaterialButton(
color: Colors.green,
onPressed: () async {
var document = await getTemporaryDirectory();
var storagePath = "${document.path}/opm.pcm";
var file = File(storagePath);
await file.create();
var responce =
await _internalAudioRecorderPlugin.startCapturing(
file.path, AudioFormat.encodingPCM16BIT, 44200);
print("Responce: $responce");
},
child: Text("Start Recording"),
),
MaterialButton(
color: Colors.green,
onPressed: () async {
var responce =
await _internalAudioRecorderPlugin.stopCapturing();
print("Responce: $responce");
},
child: Text("Stop Recording"),
),
],
),
),
),
);
}
}