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.
<preference name="UseLegacySwiftLanguageVersion" value="true" />
Supported Platforms
- iOS
- Android
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);
});
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);
});
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