AudioUtils
这里提供了某些场景可能会用到的音频相关的工具函数,主要用于 外部音频导入
或者 音乐混音
。
通过如下方式来访问 AudioUtils 里暴露的函数:
import { AudioUtils } from "pili-rtc-web";
// 或者 import * as QNRTC from "pili-rtc-web";
// const AudioUtils = QNRTC.AudioUtils;
const manager = AudioUtils.createAudioMixingManagerFromTrack(track);
createAudioMixingManagerFromTrack(track)
Track
track:AudioTrackMixingManager
返回:将传入的 Track 作为混音源创建一个混音模块,注意传入的 Track 必须是 audio
类型的
关于混音的具体用法可以参考文档指南中的 音乐混音
和相应模式的混音模块 API。
createAudioMixingManagerFromStream(stream)
Stream
stream:AudioStreamMixingManager
返回:将传入的 Stream 作为混音源创建一个混音模块,注意传入的 Stream 必须要开启了音频
关于混音的具体用法可以参考文档指南中的 音乐混音
和相应模式的混音模块 API。
decodeAudioData(data)
ArrayBuffer
data:AudioBuffer>
返回 Promise<传入一个 ArrayBuffer(可以通过用户上传的文件或者请求返回的 Buffer 里获取),Promise
返回一个解码后的 AudioBuffer。