Module: miot/host/audio

音频处理

Example
import {Host} from 'miot'
...
Host.audio.startRecord('sample', {'AVFormatIDKey': 'AMR'})
 .then(res => {//start record success})
...
Host.audio.stopRecord().then(res => {//stop finished})
...

Namespaces

AudioEvent

Methods

(static) amrToWav(amrPath, savePath) → {Promise}

amr 转 wav

Parameters:
Name Type Description
amrPath string

读取 amr 文件名

savePath string

保存 wav 文件名

Returns:
Type
Promise

(static) isAbleToRecord() → {boolean}

用户是否开启录制权限

Returns:
Type
boolean

(static) startPlay(audioName, settings) → {Promise}

开始播放

Parameters:
Name Type Description
audioName string

文件名

settings json

配置参数 updateAudioPlayerTimeInterval 回调间隔, audioPlayerUid 音频的唯一标识

Returns:
Type
Promise

(static) startRecord(audioName, settings) → {Promise}

开始录音

Parameters:
Name Type Description
audioName string

保存文件名,如 audio.mp3

settings json

配置参数{ AVSampleRateKey 采样率 默认44100, AVNumberOfChannelsKey 声道,默认2, AVLinearPCMBitDepthKey 音频编码比特率 默认16, AVFormatIDKey 编码格式(AMR,AMR_WB,MPEG4AAC,MPEG4CELP,MPEG4HVXC,MPEG4TwinVQ,AC3,60958AC3), AVEncoderAudioQualityKey 音质(Min,Low,Medium,High,Max) }

Returns:
Type
Promise

(static) stopPlay() → {Promise}

停止播放

Returns:
Type
Promise

(static) stopRecord() → {Promise}

停止录音

Returns:
Type
Promise

(static) wavToAmr(wavPath, savePath) → {Promise}

wav转 amr

Parameters:
Name Type Description
wavPath string

读取 wav 文件名

savePath string

保存 amr 文件名

Returns:
Type
Promise