MCPcopy Index your code
hub / github.com/akofman/cordova-plugin-dbmeter

github.com/akofman/cordova-plugin-dbmeter @2.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.0.1 ↗ · + Follow
15 symbols 40 edges 4 files 10 documented · 67%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Twitter: @alexiskofman License Build Status

cordova-plugin-dbmeter

This plugin defines a global DBMeter object, which permits to get the decibel values from the microphone. Although the object is in the global scope, it is not available until after the deviceready event.

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    DBMeter.start(function(dB){
        console.log(dB);
    });
}

Installation

cordova plugin add cordova-plugin-dbmeter

The iOS part is written in Swift so the Swift support plugin is configured as a dependency in plugin.xml.

:warning: Because this plugin doesn't support Swift 3 at the moment, the following preference has to be added in your project :

<preference name="UseLegacySwiftLanguageVersion" value="true" />

Supported Platforms

  • iOS
  • Android

iOS Quirks

Since iOS 10 it's mandatory to provide an usage description in the info.plist if trying to access privacy-sensitive data. When the system prompts the user to allow access, this usage description string will displayed as part of the permission dialog box, but if you didn't provide the usage description, the app will crash before showing the dialog. Also, Apple will reject apps that access private data but don't provide an usage description.

This plugins requires the following usage description:

  • NSMicrophoneUsageDescription describes the reason the app accesses the user's microphone.

To add this entry into the info.plist, you can use the edit-config tag in the platform section of your config.xml like this:

<edit-config target="NSMicrophoneUsageDescription" file="*-Info.plist" mode="merge">
    <string>need microphone access to record sounds</string>
</edit-config>

Methods

DBMeter.start(success, error)

start listening.

DBMeter.start(function(dB){
  console.log(dB);
}, function(e){
  console.log('code: ' + e.code + ', message: ' + e.message);
});

DBMeter.stop(success, error)

stop listening.

DBMeter.stop(function(){
  console.log("DBMeter well stopped");
}, function(e){
  console.log('code: ' + e.code + ', message: ' + e.message);  
});

:warning: If the DBMeter is stopped while is not listening, an error will be triggered and can be handle from the second callback argument.

DBMeter.isListening(success, error)

retrieve from the success callback whether the DBMeter is listening.

DBMeter.isListening(function(isListening){
  console.log(isListening);
});

DBMeter.delete(success, error)

delete the DBMeter instance.

DBMeter.delete(function(){
  console.log("Well done !");
}, function(e){
  console.log('code: ' + e.code + ', message: ' + e.message);  
});

:warning: If the DBMeter has not been started once before deleting, an error will be triggered and can be handle from the second callback argument.

App

An app is available in the app folder and is generated from the Cordova Plugin Test Framework. It permits to launch auto tests and manual tests.

To install it, please follow these steps :

cd app && cordova platform add android|ios
cordova run android|ios --device

Core symbols most depended-on inside this repo

stop
called by 8
src/android/DBMeter.java
start
called by 7
src/android/DBMeter.java
isListening
called by 7
src/android/DBMeter.java
execute
called by 2
src/android/DBMeter.java
sendPluginError
called by 2
src/android/DBMeter.java
requestPermission
called by 1
src/android/PermissionHelper.java
requestPermissions
called by 1
src/android/PermissionHelper.java
hasPermission
called by 1
src/android/PermissionHelper.java

Shape

Method 11
Class 2
Enum 1
Function 1

Languages

Java93%
TypeScript7%

Modules by API surface

src/android/DBMeter.java9 symbols
src/android/PermissionHelper.java5 symbols
tests/tests.js1 symbols

For agents

$ claude mcp add cordova-plugin-dbmeter \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page