2016-03-14 01:34:19 +08:00
|
|
|
import {Plugin, Cordova} from './plugin'
|
2016-03-14 03:05:15 +08:00
|
|
|
import {Observable} from "rxjs/Observable";
|
2016-03-14 01:34:19 +08:00
|
|
|
/**
|
|
|
|
* @name DB Meter
|
2016-03-14 03:05:15 +08:00
|
|
|
* @description This plugin defines a global DBMeter object, which permits to get the decibel values from the microphone.
|
2016-03-14 01:34:19 +08:00
|
|
|
* @platforms Android, iOS
|
|
|
|
* @usage
|
2016-03-14 03:05:15 +08:00
|
|
|
* ```ts
|
|
|
|
* // Start listening
|
|
|
|
* let subscription = DBMeter.start().subscribe(
|
|
|
|
* data => console.log(data)
|
|
|
|
* );
|
|
|
|
*
|
|
|
|
* // Check if we are listening
|
|
|
|
* DBMeter.isListening().then(
|
|
|
|
* (isListening : boolean) => console.log(isListening)
|
|
|
|
* );
|
|
|
|
*
|
|
|
|
* // Stop listening
|
|
|
|
* subscription.unsubscribe();
|
|
|
|
*
|
|
|
|
* // Delete DBMeter instance from memory
|
|
|
|
* DBMeter.delete().then(
|
|
|
|
* () => console.log("Deleted DB Meter instance"),
|
|
|
|
* error => console.log("Error occurred while deleting DB Meter instance")
|
|
|
|
* );
|
|
|
|
* ```
|
2016-03-14 01:34:19 +08:00
|
|
|
*/
|
|
|
|
@Plugin({
|
|
|
|
plugin: 'cordova-plugin-dbmeter',
|
|
|
|
pluginRef: 'DBMeter',
|
|
|
|
repo: 'https://github.com/akofman/cordova-plugin-dbmeter'
|
|
|
|
})
|
|
|
|
export class DBMeter {
|
|
|
|
|
2016-03-14 03:05:15 +08:00
|
|
|
/**
|
|
|
|
* Starts listening
|
|
|
|
* @return {Observable<string>} Returns an observable. Subscribe to start listening. Unsubscribe to stop listening.
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
observable: true,
|
|
|
|
clearFunction: 'stop'
|
|
|
|
})
|
|
|
|
static start () : Observable<any> {return}
|
2016-03-14 01:34:19 +08:00
|
|
|
|
2016-03-14 03:05:15 +08:00
|
|
|
/**
|
|
|
|
* Stops listening
|
|
|
|
* @private
|
|
|
|
*/
|
2016-03-14 01:34:19 +08:00
|
|
|
@Cordova()
|
|
|
|
static stop () : Promise<any> {return}
|
|
|
|
|
2016-03-14 03:05:15 +08:00
|
|
|
/**
|
|
|
|
* Check if the DB Meter is listening
|
|
|
|
* @return {Promise<boolean>} Returns a promise that resolves with a boolean that tells us whether the DB meter is listening
|
|
|
|
*/
|
2016-03-14 01:34:19 +08:00
|
|
|
@Cordova()
|
|
|
|
static isListening() : Promise<boolean> {return}
|
|
|
|
|
2016-03-14 03:05:15 +08:00
|
|
|
/**
|
|
|
|
* Delete the DB Meter instance
|
|
|
|
* @return {Promise<any>} Returns a promise that will resolve if the instance has been deleted, and rejects if errors occur.
|
|
|
|
*/
|
2016-03-14 01:34:19 +08:00
|
|
|
@Cordova()
|
|
|
|
static delete() : Promise<any> {return}
|
|
|
|
|
|
|
|
}
|