zaraclaj / audio_recorder Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
How can i modify the plugin to get raw pcm data (16KHZ, 16 bit LE) in real time to be sent to speech recognition server?
Technically at the moment this project is proprietary because it has no license.
Please add an open source license.
when i use Flutter 1.7.3, flutter run appear the following error
/Users/yfb/flutter/.pub-cache/hosted/pub.flutter-io.cn/audio_recorder-1.0.2/ios/Classes/SwiftAudioRecorderPlugin.swift:39:108: error:
'AVAudioSessionCategoryOptions' has been renamed to 'AVAudioSession.CategoryOptions'
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, with:
AVAudioSessionCategoryOptions.defaultToSpeaker)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AVAudioSession.CategoryOptions
AVFoundation.AVAudioSessionCategoryOptions:2:18: note: 'AVAudioSessionCategoryOptions' was obsoleted in Swift 4.2
public typealias AVAudioSessionCategoryOptions = AVAudioSession.CategoryOptions
^
/Users/yfb/flutter/.pub-cache/hosted/pub.flutter-io.cn/audio_recorder-1.0.2/ios/Classes/SwiftAudioRecorderPlugin.swift:67:52: error: cannot call value
of non-function type 'AVAudioSession.RecordPermission'
switch AVAudioSession.sharedInstance().recordPermission(){
Cannot build my project after including audio_recorder: "^0.0.2"
.
Launching lib/main.dart on iPhone 5s in debug mode...
Skipping compilation. Fingerprint match.
Xcode build done.
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.
Could not build the application for the simulator.
Error launching application on iPhone 5s.
Exited (sigterm)
libraries will need to be updated for dart 2 preview eventuallly.
it currently breaks on the preview which is the default for flutter.
'_Future' is not a subtype of type 'Future
https://groups.google.com/forum/#!topic/flutter-dev/H8dDhWg_c8I
audio_recorder
does not specify a Swift version and none of the targets (Runner
) integrating it have the SWIFT_VERSION
attribute set. Please contact the author or set the SWIFT_VERSION
attribute in at least one of the targets that integrate this podWhen I press my button that start the recording I get this exception:
I am running on a motorola Android device Moto G5S
D/AudioRecorder(29157): Start
D/AudioRecorder(29157): /storage/emulated/0.m4a
E/AudioRecorder(29157): prepare() failed
E/MediaRecorder(29157): start called in an invalid state: 4
E/MethodChannel#audio_recorder(29157): Failed to handle method call
E/MethodChannel#audio_recorder(29157): java.lang.IllegalStateException
E/MethodChannel#audio_recorder(29157): at android.media.MediaRecorder.start(Native Method)
E/MethodChannel#audio_recorder(29157): at com.jordanalcaraz.audiorecorder.audiorecorder.AudioRecorderPlugin.startRecording(AudioRecorderPlugin.java:107)
E/MethodChannel#audio_recorder(29157): at com.jordanalcaraz.audiorecorder.audiorecorder.AudioRecorderPlugin.onMethodCall(AudioRecorderPlugin.java:59)
E/MethodChannel#audio_recorder(29157): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191)
E/MethodChannel#audio_recorder(29157): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
E/MethodChannel#audio_recorder(29157): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#audio_recorder(29157): at android.os.MessageQueue.next(MessageQueue.java:323)
E/MethodChannel#audio_recorder(29157): at android.os.Looper.loop(Looper.java:136)
E/MethodChannel#audio_recorder(29157): at android.app.ActivityThread.main(ActivityThread.java:6165)
E/MethodChannel#audio_recorder(29157): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#audio_recorder(29157): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
E/MethodChannel#audio_recorder(29157): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
My code that executes the recording is:
void _recordingButtonClick() async {
Directory dir = await path.getExternalStorageDirectory();
print("has permission: ${await AudioRecorder.hasPermissions}");
if (await AudioRecorder.hasPermissions) {
if (isRecording) {
AudioRecorder.stop();
setState(() {
isRecording = false;
});
} else {
AudioRecorder.start(
path: dir.path, audioOutputFormat: AudioOutputFormat.AAC);
setState(() {
isRecording = true;
});
}
} else {
await SimplePermissions.requestPermission(Permission.RecordAudio);
await SimplePermissions.requestPermission(Permission.WriteExternalStorage);
}
}
/flutter/.pub-cache/hosted/pub.dartlang.org/audio_recorder-1.0.2/ios/Classes/SwiftAudioRecorderPlugin.swift:39:108: error: 'AVAudioSessionCategoryOptions' has been renamed to 'AVAudioSession.CategoryOptions'
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, with: AVAudioSessionCategoryOptions.defaultToSpeaker)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AVAudioSession.CategoryOptions
AVFoundation.AVAudioSessionCategoryOptions:2:18: note: 'AVAudioSessionCategoryOptions' was obsoleted in Swift 4.2
public typealias AVAudioSessionCategoryOptions = AVAudioSession.CategoryOptions
^
/flutter/.pub-cache/hosted/pub.dartlang.org/audio_recorder-1.0.2/ios/Classes/SwiftAudioRecorderPlugin.swift:67:52: error: cannot call value of non-function type 'AVAudioSession.RecordPermission'
switch AVAudioSession.sharedInstance().recordPermission(){
flutter doctor -v
[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.3 19D76, locale en)
• Flutter version 1.12.13+hotfix.9 at /Users/henan_kefa/Development/flutter
• Framework revision f139b11009 (4 days ago), 2020-03-30 13:57:30 -0700
• Engine revision af51afceb8
• Dart version 2.7.2
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/setup/#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
You may also want to add it to your PATH environment variable.
[✓] Xcode - develop for iOS and macOS (Xcode 11.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.4, Build version 11E146
• CocoaPods version 1.9.1
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/setup/#android-setup for detailed instructions).
[✓] VS Code (version 1.43.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.8.1
[✓] Connected device (1 available)
• iPhone 11 Pro Max • 929D6746-F0B3-4B5B-8244-3A1756C1306D • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-4
(simulator)
Thanks for your great work!
I just wanted to add this plugin to a project, but unfortunately, the license is missing in the automatically generated licenses dialog in Android.
For demonstration purpose, the source of a minimal example:
pubspec.yaml:
name: arlicense
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
audio_recorder: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
main.dart:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'ARLicense',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Scaffold(
body: Center(
child: Builder(
builder: (context) => FlatButton(
onPressed: () => showAboutDialog(context: context),
child: Text("showAboutDialog"))))));
}
}
Steps to reproduce:
showAboutDialog
View licenses
I saw, that you already added a license to the project (- I think it is BSD?) - but as shown above, it seems not working - at least for me.
Best regards
Stefan
I am getting following error after including the plugin
Compiler message:
file:///Users/apurv2017/dev/flutter/.pub-cache/hosted/pub.dartlang.org/audio_recorder-0.0.6/lib/audio_recorder.dart:49:13: Error: A constructor invocation can't have type arguments on the constructor name.
Try to place the type arguments on the class name.
Map.from<String, Object>(await _channel.invokeMethod('stop'));
^^^^
Compiler failed on /Users/apurv2017/AndroidStudioProjects/app_name/lib/main.dart
Finished with error: Gradle task assembleDebug failed with exit code 1
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.10.2, on Mac OS X 10.13.6 17G65, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.2)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.0)
[✓] Android Studio (version 3.2)
[!] VS Code (version 1.28.2)
[✓] Connected device (1 available)
Hi Guys,
Using latest version of Audio_recorder plugin and it is not working on IOS, i have target ios version(10), Any thoughts?
Xcode's output:
↳
=== BUILD TARGET sqflite OF PROJECT Pods WITH CONFIGURATION Debug ===
/Users/user/flutter-dev/flutter/.pub-cache/hosted/pub.dartlang.org/audio_recorder-1.0.1/ios/Classes/SwiftAudioRecorderPlugin.swift:40:23: error:
'AVAudioSessionCategoryOptions' has been renamed to 'AVAudioSession.CategoryOptions'
with: AVAudioSessionCategoryOptions.defaultToSpeaker)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AVAudioSession.CategoryOptions
AVFoundation.AVAudioSessionCategoryOptions:2:18: note: 'AVAudioSessionCategoryOptions' was obsoleted in Swift 4.2
public typealias AVAudioSessionCategoryOptions = AVAudioSession.CategoryOptions
^
/Users/user/flutter-dev/flutter/.pub-cache/hosted/pub.dartlang.org/audio_recorder-1.0.1/ios/Classes/SwiftAudioRecorderPlugin.swift:68:68: error: cannot call value of
non-function type 'AVAudioSession.RecordPermission'
switch AVAudioSession.sharedInstance().recordPermission(){
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
Could not build the application for the simulator.
Error launching application on iPhone Xʀ.
Flutter 0.8.2 • channel beta • https://github.com/flutter/flutter.git
Framework • revision 5ab9e70727 (3 weeks ago) • 2018-09-07 12:33:05 -0700
Engine • revision 58a1894a1c
Tools • Dart 2.1.0-dev.3.1.flutter-760a9690c2
E/MethodChannel#audio_recorder(21439): Failed to handle method call
E/MethodChannel#audio_recorder(21439): java.lang.IllegalStateException
E/MethodChannel#audio_recorder(21439): at android.media.MediaRecorder._start(Native Method)
E/MethodChannel#audio_recorder(21439): at android.media.MediaRecorder.start(MediaRecorder.java:1175)
E/MethodChannel#audio_recorder(21439): at com.jordanalcaraz.audiorecorder.audiorecorder.AudioRecorderPlugin.startRecording(AudioRecorderPlugin.java:107)
E/MethodChannel#audio_recorder(21439): at com.jordanalcaraz.audiorecorder.audiorecorder.AudioRecorderPlugin.onMethodCall(AudioRecorderPlugin.java:59)
E/MethodChannel#audio_recorder(21439): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191)
E/MethodChannel#audio_recorder(21439): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
E/MethodChannel#audio_recorder(21439): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#audio_recorder(21439): at android.os.MessageQueue.next(MessageQueue.java:323)
E/MethodChannel#audio_recorder(21439): at android.os.Looper.loop(Looper.java:136)
E/MethodChannel#audio_recorder(21439): at android.app.ActivityThread.main(ActivityThread.java:6682)
E/MethodChannel#audio_recorder(21439): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#audio_recorder(21439): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
E/MethodChannel#audio_recorder(21439): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
I/flutter (21439): PlatformException(error, null, null)
Android record default encoder is AMR,so if record in android, can't play in IOS.
The library works great when running in iOS simulator. But on a physical iPhone, it is only creating a 28 byte mp4 file which is basically the header information. None of the actual audio content is getting written to the file.
I am including the NSMicrophoneUsageDescription key and have permission enabled for the microphone.
There are no errors reported by the library, but I see several of these messages in the console after starting the recording:
mediaserverd 1111: AudioConverterNew returned -50
Other reports suggest that these message indicate the system might be having trouble accessing a microphone. But I have an Xcode app that can successfully record on the same device without this problem.
i am recording VoIP (WhatsApp/facebook) call using this plugin but it's not working
Title basically. Need to support saving audio as WAV files.
Basically allowing me to listen and on the fly do stuff in my app while I'm recording.
Hi, this plugins works for me except when a file was recorded on an Android and than played on an iPhone. I can record/play within an iPhone, I can record/play within android. I can reproduce in an Android audio recorded on an iPhone but I can't reproduce on an iPhone audio recorder on an Android. I hope the tong twist makes sense
I tried both playing the file straight from http and also downloading it locally and playing it afterwards.
Any ideas?
PS: My code is pretty vanilla from the example hence why I didn't include it
Hi Everyone,
i'm facing a problem for 1 week.
Recording start and stop correctly, i get the exact duration but when i upload the audioFile in Firebase Storage, i can see the size equal to zero.
Microphone permission is granted, and no have idea when this issue would come from.
Thanks for your help.
@ZaraclaJ
Hi, thanks for the awesome plugin.
I have this issue:
While recording, in the case of an incoming phone call, audio gets corrupted (reduced to one sec) on iOS.
To handle this, I created this plugin https://pub.dartlang.org/packages/phone_state_i
which creates a call back for phone call states and I stop recording.
But after this, I realised that iOS still corrupting the recording, After digging more I figured that probably interruptions are not handled by your plugin. (https://stackoverflow.com/questions/31733559/handling-interruptions-with-avaudiorecorder)
I wanted to ask you if you can implement this method(handling interruptions) in the plugin?
Hello, when i try to import the library audio_recorder I receive this error:
Couldn't read file LocalFile: 'C:\Devel\flutter.pub-cache\hosted\pub.dartlang.org\audio_recorder-1.0.1\android\src\main\kotlin\com\jordanalcaraz\audiorecorder\audiorecorder\AudioRecorderPlugin.kt' even though it exists. Please verify that this file has read permission and try again.
I don't know why it is searching for kotlin files and not java but the result it's I'm not able to use it
switch AVAudioSession.sharedInstance().recordPermission{
case AVAudioSession.RecordPermission.granted:
print("granted")
hasPermissions = true
break
case AVAudioSession.RecordPermission.denied:
print("denied")
hasPermissions = false
break
case AVAudioSession.RecordPermission.undetermined:
print("undetermined")
AVAudioSession.sharedInstance().requestRecordPermission() { [unowned self] allowed in
DispatchQueue.main.async {
if allowed {
self.hasPermissions = true
} else {
self.hasPermissions = false
}
}
}
break
default:
break
}
I'm trying to build for IOS, but keep coming across these exceptions:
Enum case 'granted' is not a member of type '() -> AVAudioSessionRecordPermission'
Enum case 'denied' is not a member of type '() -> AVAudioSessionRecordPermission'
Enum case 'undetermined' is not a member of type '() -> AVAudioSessionRecordPermission'
Any help would be appreciated,
Thanks
Hi guys,
found following error while trying 'pod install' in the /ios folder - Any fixes?
Unable to determine Swift version for the following pods:
audio_recorder
does not specify a Swift version and none of the targets (Runner
) integrating it have the SWIFT_VERSION
attribute set. Please contact the author or set the SWIFT_VERSION
attribute in at least one of the targets that integrate this pod.@ZaraclaJ I have been beating my head around the neighborhood trying to find an audio recorder that is compatible with Google Speech-to-text cloud API. Sadly none of the formats that are supported in your recorder, qualify for the conversion.
With a lot of apps being created with firebase and flutter combo, this seems to be a bottleneck, technology-wise.
Ref: https://cloud.google.com/speech-to-text/docs/encoding
Some handy additions would be:
Hi,
I am getting issue in adding audio_recorder
package to project. This is because of path_provider
package is incompatible with other packages. Error details:
Because audio_recorder >=0.0.5 depends on path_provider ^0.4.1 and contacts_service 0.2.2 depends on path_provider ^0.5.0+1, audio_recorder >=0.0.5 is incompatible with contacts_service 0.2.2.
So, because securityguard depends on both contacts_service 0.2.2 and audio_recorder ^0.0.6, version solving failed.
Please, you need to change the lines 39 and 67 respectively as below:
39 - try AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: [])
67 - switch AVAudioSession.sharedInstance().recordPermission{
This is the correct implementation. Your current build is wrong and crashes.
Package audio_recorder depends on file: ^5.0.4
As per Flutter 1.22 this needs to be updated to file: ^6.0.0-nullsafety.2
Because testWidgets()
is not run in real time, it appears to be not possible to make dart async calls to file system when testing widgets. Since this plugin accesses the file system in dart code, my tests for widgets that use this plugin are failing, for example, when calling AudioRecorder.start()
.
Google provides a file system abstraction package that addresses this problem. I was able to use this package to get widget tests to work (using mocking). Required making a minor change to the plugin's dart code (1 new line, 1 modified line, no change to API).
I can do a PR for this if interested (or add to existing PR #17). Let me know 👍
Is there a way to reverse audio after recording?
audio_recorder-0.0.6/lib/audio_recorder.dart:49:13: Error: A constructor invocation can't have type arguments on the constructor name.
Try to place the type arguments on the class name.
Map.from<String, Object>(await _channel.invokeMethod('stop'));
As far as I can tell, a few of the past commits have brought this plugin up to date with the current Dart version, and should therefore be updated to reflect that so it can be safely used in up to date Flutter apps.
If I am wrong in this, let me know if there is any way I can help the process along and I would love to contribute.
Launching lib/main.dart on Android SDK built for x86 in debug mode...
[!] Your app isn't using AndroidX.
To avoid potential build failures, you can quickly migrate your app by following the steps on https://goo.gl/CP92wY.
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> More than one file was found with OS independent path 'META-INF/proguard/androidx-annotations.pro'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 9s
AndroidX incompatibilities may have caused this build to fail. Please migrate your app to AndroidX. See https://goo.gl/CP92wY.
Finished with error: Gradle task assembleDebug failed with exit code 1
It can be fixed with the following code in build.gradle inside android {}
:
packagingOptions { exclude 'META-INF/proguard/androidx-annotations.pro' }
My app is able to record and save on Android, but not on iOS.
When stopping record, it returns a empty audio file with .m4a saying
File length: 28
When I open the file, it does not start anything
Any help will be appreciated
FYI: The build of the example for android has some gradle config problems due to breaking changes of the package dependency path_provider
as of version 0.3.0.
Using these instructions, the following diffs allowed me to run the example (though I had to enable access to the mic and storage manually after installing):
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index 45e7f14..aa901e1 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle
index 4bc7bef..d0b6555 100644
--- a/example/android/app/build.gradle
+++ b/example/android/app/build.gradle
@@ -15,8 +15,8 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
- compileSdkVersion 25
- buildToolsVersion '25.0.3'
+ compileSdkVersion 27
+ buildToolsVersion '27.0.3'
lintOptions {
disable 'InvalidPackage'
@@ -26,7 +26,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.jordanalcaraz.audiorecorder.audiorecorderexample"
minSdkVersion 16
- targetSdkVersion 25
+ targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
diff --git a/example/android/build.gradle b/example/android/build.gradle
index 77cbd09..4476887 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -1,28 +1,26 @@
buildscript {
repositories {
+ google()
jcenter()
- maven {
- url "https://maven.google.com"
- }
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.3.3'
+ classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
+ google()
jcenter()
- maven {
- url "https://maven.google.com"
- }
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
+}
+subprojects {
project.evaluationDependsOn(':app')
}
Hi, thanks for package!
Is it possible to change audio quality(bit rate.. etc)?
Not work on IOS
there are lots of issues about the deprecation of some functions in this library. can someone please tell me what's going on with this project?
Added these to four files but can't get past SnackBar message:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Android Studio for Flutter.
if I try start recording for two times, the first try succeeded but the second try throw exception, even the output file of the first try isn't a valid file.
01-18 14:12:27.135 18270-18270/org.crcis.nooryab E/MediaRecorder: start failed: -2147483648
01-18 14:12:27.135 18270-18270/org.crcis.nooryab E/MethodChannel#audio_recorder: Failed to handle method call
java.lang.RuntimeException: start failed.
at android.media.MediaRecorder.start(Native Method)
at com.jordanalcaraz.audiorecorder.audiorecorder.AudioRecorderPlugin.startRecording(AudioRecorderPlugin.java:107)
at com.jordanalcaraz.audiorecorder.audiorecorder.AudioRecorderPlugin.onMethodCall(AudioRecorderPlugin.java:59)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191)
at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:136)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:136)
at android.os.Looper.loop(Looper.java:197)
at android.app.ActivityThread.main(ActivityThread.java:5225)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
01-18 14:12:27.155 18270-18311/org.crcis.nooryab E/flutter: [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
PlatformException(error, start failed., null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:547:7)
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:279:18)
<asynchronous suspension>
#2 AudioRecorder.start (package:audio_recorder/audio_recorder.dart:38:21)
<asynchronous suspension>
#3 _QuranState._startRecording (package:nooryab/routes/quran_page.dart:119:25)
<asynchronous suspension>
#4 _QuranState._getSearchbar.<anonymous closure> (package:nooryab/routes/quran_page.dart:137:15)
#5 TapGestureRecognizer._checkDown.<anonymous closure> (package:flutter/src/gestures/tap.dart:142:48)
#6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
#7 TapGestureRecognizer._checkDown (package:flutter/src/gestures/tap.dart:142:9)
#8 TapGestureRecognizer.didExceedDeadline (package:flutter/src/gestures/tap.dart:114:5)
#9 Timer._createTimer.<anonymous closure> (dart:async/runtime/libtimer_patch.dart:21:15)
#10 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
#11 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
#12 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
How to make it stop recording when duration larger than 10 seconds?
Flutter1.12.13 build has problem,because your packages name is not as the same as path,please check
your package name is com.jordanalcaraz.audiorecorder.audiorecorder,but your path is com.jordanalcaraz.audiorecorder.audio_recorder
If you quickly start and stop a recording, a RuntimeException
is thrown from Java, resulting in a PlatformException
in Flutter:
D/AudioRecorder(12194): Start
D/AudioRecorder(12194): /data/user/0/dev.hugopassos.buster/cache/af313050-56be-4ec8-b821-2cad871a9cc7.m4a
D/AudioRecorder(12194): Stop
E/MediaRecorder(12194): stop failed: -1007
E/MethodChannel#audio_recorder(12194): Failed to handle method call
E/MethodChannel#audio_recorder(12194): java.lang.RuntimeException: stop failed.
E/MethodChannel#audio_recorder(12194): at android.media.MediaRecorder.stop(Native Method)
E/MethodChannel#audio_recorder(12194): at com.jordanalcaraz.audiorecorder.audiorecorder.AudioRecorderPlugin.stopNormalRecording(AudioRecorderPlugin.java:134)
E/MethodChannel#audio_recorder(12194): at com.jordanalcaraz.audiorecorder.audiorecorder.AudioRecorderPlugin.stopRecording(AudioRecorderPlugin.java:128)
E/MethodChannel#audio_recorder(12194): at com.jordanalcaraz.audiorecorder.audiorecorder.AudioRecorderPlugin.onMethodCall(AudioRecorderPlugin.java:66)
E/MethodChannel#audio_recorder(12194): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#audio_recorder(12194): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#audio_recorder(12194): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643)
E/MethodChannel#audio_recorder(12194): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#audio_recorder(12194): at android.os.MessageQueue.next(MessageQueue.java:325)
E/MethodChannel#audio_recorder(12194): at android.os.Looper.loop(Looper.java:142)
E/MethodChannel#audio_recorder(12194): at android.app.ActivityThread.main(ActivityThread.java:6494)
E/MethodChannel#audio_recorder(12194): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#audio_recorder(12194): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
E/MethodChannel#audio_recorder(12194): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
E/flutter (12194): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, stop failed., null)
E/flutter (12194): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
E/flutter (12194): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
E/flutter (12194): <asynchronous suspension>
E/flutter (12194): #2 AudioRecorder.stop (package:audio_recorder/audio_recorder.dart:49:33)
E/flutter (12194): <asynchronous suspension>
E/flutter (12194): #3 new Future.delayed.<anonymous closure> (dart:async/future.dart:316:39)
E/flutter (12194): #4 _rootRun (dart:async/zone.dart:1120:38)
E/flutter (12194): #5 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (12194): #6 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter (12194): #7 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
E/flutter (12194): #8 _rootRun (dart:async/zone.dart:1124:13)
E/flutter (12194): #9 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (12194): #10 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
E/flutter (12194): #11 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:21:15)
E/flutter (12194): #12 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)
E/flutter (12194): #13 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
E/flutter (12194): #14 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
You should be able to reproduce this issue with the following snippet:
import 'package:audio_recorder/audio_recorder.dart';
import 'package:flutter/material.dart';
import 'package:path/path.dart';
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:uuid/uuid.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Foo(),
);
}
}
class Foo extends StatelessWidget {
static final _uuid = Uuid();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: RaisedButton(
child: Text('Quickly start and stop recording'),
onPressed: quicklyStartAndStopRecording,
),
),
);
}
Future<void> quicklyStartAndStopRecording() async {
await PermissionHandler().requestPermissions([PermissionGroup.microphone]);
final directory = await getTemporaryDirectory();
final path = join(directory.path, '${_uuid.v4()}.m4a');
await AudioRecorder.start(
path: path,
audioOutputFormat: AudioOutputFormat.AAC,
);
await Future.delayed(
const Duration(milliseconds: 100),
AudioRecorder.stop,
);
}
}
Pubspec dependencies:
dependencies:
flutter:
sdk: flutter
path_provider: ^1.3.0
path: ^1.6.2
uuid: ^2.0.2
permission_handler: ^3.2.2
audio_recorder: ^1.0.1
MissingPluginException(No implementation found for method hasPermissions on channel audio_recorder)
Instructions on the dart package readme says:
import 'package:flutter_audio_recorder_plugin/flutter_audio_recorder_plugin.dart';
but the example says:
import 'package:audio_recorder/audio_recorder.dart';
Is this repo in active development:?
I see some pull requests ect.. but no response from you.
Hello Jordan, I am not able to get permissions to record audio with your example.
Also, I did include the permissions in the manifest:
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.RECORD_AUDIO"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
I tried with an emulated Pixel 2 XL and a real Pixel with the same result.
I am not an expert Android developer, but I don't see any ContextCompat.checkSelfPermission
in your plugin. Could that be the problem?
Thanks in advance
Hi.
I am trying to send messages betweenAndroid and iOS devices in my chat app. Audio that is recorded on Android won't play in iOS.
There is no issue the other way around when messages are sent from iOS to Android.
This issue was present on flutter_sound plugin but was fixed lately. Here is the issue Canardoux/flutter_sound#155;
Unfortunately I can't use flutter sound in my app for some unknown reason. My app is complex and has many plugins this probably could be the reason.
Any help is appreciated.
Thanks.
I have build error:
` ** BUILD FAILED **
Xcode's output:
↳
=== BUILD TARGET firebase_messaging OF PROJECT Pods WITH CONFIGURATION Debug ===
.../.pub-cache/hosted/pub.dartlang.org/audio_recorder-0.0.6/ios/Classes/SwiftAudioRecorderPlugin.swift:88:13: warning: default will never be executed
default:
^
=== BUILD TARGET firebase_messaging OF PROJECT Pods WITH CONFIGURATION Debug ===
.../.pub-cache/hosted/pub.dartlang.org/audio_recorder-0.0.6/ios/Classes/AudioRecorderPlugin.m:2:9: fatal error: 'audio_recorder/audio_recorder-Swift.h' file not found
#import <audio_recorder/audio_recorder-Swift.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.`
Hi,
First, I would like to thank you for the awesome plugin.
Is there anyway to enhance the audio quality?
I compared the recording of this plugin with android recorder app where the recording of the latest sounds better. I just used the example here.
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.