@jswork/audio-utils
v1.0.12
Published
Audio utils.
Downloads
32
Maintainers
Readme
audio-utils
Audio utils.
installation
yarn add @jswork/audio-utils
usage
import { checkPermission, watchAmplitude } from '@jswork/audio-utils';
// checkPermission
checkPermission().then((res) => {
console.log(res);
});
// watchAmplitude when recorder
useEffect(() => {
if (!isPlaying) return;
const res = watchAmplitude({
type: 'recorder',
context: recorder,
callback: (v) => {
console.log('volumn: ', v);
},
});
return res.destroy;
}, [isPlaying]);
// watchAmplitude when howler
useEffect(() => {
if (!isPlaying) return;
const res = watchAmplitude({
type: 'howler',
context: Howler,
callback: (v) => {
console.log('volumn: ', v);
},
});
return res.destroy;
}, [isPlaying]);
// watchAmplitude when audio
useEffect(() => {
if (!isPlaying) return;
const res = watchAmplitude({
type: 'audio',
context: document.querySelector('#audio1'),
callback: (v) => {
console.log('volumn: ', v);
},
});
return res.destroy;
}, [isPlaying]);
types
/// <reference types="@jswork/audio-utils/global.d.ts" />
license
Code released under the MIT license.