Name Last Update
..
utssdk Loading commit data...
changelog.md Loading commit data...
package.json Loading commit data...
readme.md Loading commit data...

gl-pcm-capture

Android 端 PCM 实时采集 UTS 插件。通过 AudioRecord 在后台线程读取音频帧,以 base64 形式回调给 JS 层。

使用

import {
  startPcmCapture,
  stopPcmCapture,
  onPcmFrame,
  offPcmFrame
} from '@/uni_modules/gl-pcm-capture'

onPcmFrame((frame) => {
  console.log('pcm frame', frame.seq, frame.byteLength)
})

startPcmCapture({
  sampleRate: 16000,
  frameSize: 4096,
  success: () => console.log('started'),
  fail: (err) => console.error(err)
})

// 停止
stopPcmCapture()
offPcmFrame()

推荐通过 utils/audioStream/AudioStreamService.js 封装使用。

注意

  • 仅支持 Android App 自定义调试基座 / 正式包(标准基座会报 gl-pcm-capture not found)
  • 新增或修改 uni_modules/gl-pcm-capture 后须重新制作自定义基座
  • 需要 RECORD_AUDIO 权限
  • 与接待录音 uni-recorder-x 同时占用 MIC 时,部分机型可能冲突;生产环境推荐统一采集层(一路 MIC → framePool)