(分贝检测)DB Meter
2017-07-12 本文已影响23人
待花谢花开
DB Meter
该插件定义了一个全局DBMeter对象,它允许从麦克风获取分贝值。
Repo(备用): https://github.com/akofman/cordova-plugin-dbmeter
Installation(安装)
1.安装Cordova和Ionic原生插件:
$ ionic cordova plugin add cordova-plugin-dbmeter
$ npm install --save @ionic-native/db-meter
Supported platforms(支持平台)
Android
iOS
Usage(用法)
import { DBMeter } from '@ionic-native/db-meter';
constructor(private dbMeter: DBMeter) { }
...
// Start listening
let subscription = this.dbMeter.start().subscribe(
data => console.log(data)
);
// Check if we are listening
this.dbMeter.isListening().then(
(isListening: boolean) => console.log(isListening)
);
// Stop listening
subscription.unsubscribe();
// Delete DBMeter instance from memory
this.dbMeter.delete().then(
() => console.log('Deleted DB Meter instance'),
error => console.log('Error occurred while deleting DB Meter instance')
);
Instance Members(实例成员)
开始监听
****Returns:** Observable<any>
返回一个observable. Subscribe开始监听. Unsubscribe停止监听.
检查DB Meter是否正在监听.
****Returns:** Promise<boolean>
返回一个是否正在监听的布尔值。
删除这个DB Meter实例
****Returns:** Promise<any>
删除成功返回一个可解析的promise,删除失败reject一个错误。