alnitak / flutter_recorder

A low-level audio recorder plugin which uses miniaudio as backend and supporting all the platforms. It can detect silence and save to WAV audio file. Audio wave and FFT data can be get in real-time as for the volume level.
Apache License 2.0
21 stars 2 forks source link

fix: Example works on MacOS but throws error #1

Open naychrist opened 1 month ago

naychrist commented 1 month ago

Description

Demo runs (thanks!) but with an unhandled exception on launch

Steps To Reproduce

update macos debug.entitlements by adding:

    <key>com.apple.security.device.audio-input</key>
    <true/>

run to debug

Application throws the following error on launch

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method requestPermissions on channel flutter.baseflow.com/permissions/methods)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:332:7)
<asynchronous suspension>
#1      MethodChannelPermissionHandler.requestPermissions (package:permission_handler_platform_interface/src/method_channel/method_channel_permission_handler.dart:80:9)
<asynchronous suspension>
#2      PermissionActions.request (package:permission_handler/permission_handler.dart:109:10)
<asynchronous suspension>
#3      FuturePermissionStatusGetters.isGranted (package:permission_handler_platform_interface/src/permission_status.dart:127:40)
<asynchronous suspension>
#4      _MyAppState.initState.<anonymous closure> (package:flutter_recorder_example/main.dart:35:54)
<asynchronous suspension>

Can still init and then start capture

Expected Behavior

Should not throw error on launch

Context

MacOS 14.5, Flutter 3.24.3

alnitak commented 1 month ago

Thank you @naychrist,

the permission handler package I used doesn't support macOS. Removing that check doesn't throw anymore.

Also, I think you should enable Audio input and Downloads folder in XCode under Runner->Signin & Capabilities.

I do not have a mac or iPhone to try and I am not familiar with those. I pushed a fix for this, can you confirm it is working now?

naychrist commented 1 month ago

thanks! that did the trick :)

True, you do need to grant access to the downloads folder for recording as well. You can do this via the UI as you suggested or you can just add the following to the example/macos/Runner/DebugProfile.entitlements and example/macos/Runner/Release.entitlements

    <key>com.apple.security.device.audio-input</key>
    <true/>
    <key>com.apple.security.files.downloads.read-write</key>
    <true/>

Heads up I will post a new issue for iOS after I get a chance to look into some framework linking issues I am having here.