flutter_acrcloud 0.0.1 flutter_acrcloud: ^0.0.1 copied to clipboard
A Flutter plugin for the ACRCloud music recognition API.
flutter_acrcloud #
A Flutter plugin for the ACRCloud music recognition API. This is a third-party plugin; there is no relation between the developer and ACRCloud.
Note: I built this plugin to support a personal project. As such, it is very bare bones and potentially buggy. If you encounter a bug or need a feature added, you can open an issue or, better yet, fix it yourself and submit a PR.
Setup #
In order to get access to the microphone, you have to explicitly list the required permission in your iOS and Android apps.
iOS #
-
Open
ios/Runner/Info.plist
. -
Add the following lines somewhere inside of the
<dict>
:<key>NSMicrophoneUsageDescription</key> <string>Recognize the music around you</string>
-
You can replace the
<string>
with whatever message you want. This message will be displayed in the alert that asks the user to grant permission to access to the microphone.
Android #
-
Open
android/app/src/main/AndroidManifest.xml
-
Add the following line inside of the
<manifest>
and above the<application>
:<uses-permission android:name="android.permission.RECORD_AUDIO" />
Usage #
Consult the example
app for a real-world example.
- Call
ACRCloud.setUp()
to provide your API key, API secret, and preferred host.setUp()
takes an instance ofACRCloudConfig
. - When you want to recognize a song, call
ACRCloud.startSession()
to start a recording session. You will get an instance ofACRCloudSession
that you can use to interact with the session. - To get the current volume, you can use the
volume
property ofACRCloudSession
. This is aStream
that is updated every time a new volume value is recoded. - To cancel a session, just call
cancel()
on the session. - To get the result of a session, you can
await
theresult
property of the session. If the result isnull
, then the request was cancelled. Otherwise, you'll get an instance ofACRCloudResponse
that contains all the information.