awesome-cordova-plugins/src/plugins/dbmeter.ts

74 lines
1.8 KiB
TypeScript
Raw Normal View History

2016-07-08 06:50:46 +08:00
import { Cordova, Plugin } from './plugin';
2016-09-22 04:04:46 +08:00
import { Observable } from 'rxjs/Observable';
2016-07-08 06:50:46 +08:00
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
* @usage
* ```typescript
* import { DBMeter } from 'ionic-native';
*
*
2016-03-14 03:05:15 +08:00
* // Start listening
* let subscription = DBMeter.start().subscribe(
* data => console.log(data)
* );
*
* // Check if we are listening
* DBMeter.isListening().then(
* (isListening: boolean) => console.log(isListening)
2016-03-14 03:05:15 +08:00
* );
*
* // 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 03:05:15 +08:00
* );
* ```
2016-03-14 01:34:19 +08:00
*/
@Plugin({
2016-10-18 09:33:17 +08:00
name: 'DBMeter',
2016-03-14 01:34:19 +08:00
plugin: 'cordova-plugin-dbmeter',
pluginRef: 'DBMeter',
repo: 'https://github.com/akofman/cordova-plugin-dbmeter',
platforms: ['iOS', 'Android']
2016-03-14 01:34:19 +08:00
})
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'
})
2016-07-08 06:50:46 +08:00
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()
2016-07-08 06:50:46 +08:00
static stop(): Promise<any> { return; }
2016-03-14 01:34:19 +08:00
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()
2016-07-08 06:50:46 +08:00
static isListening(): Promise<boolean> { return; }
2016-03-14 01:34:19 +08:00
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()
2016-07-08 06:50:46 +08:00
static delete(): Promise<any> { return; }
2016-03-14 01:34:19 +08:00
2016-05-21 04:59:18 +08:00
}