@hunine/use-sound-ts
v1.1.0
Published
If you use the Audio element to play some sound with the `loop = true` property, you may encounter issues.
Readme
Support sound control using Web Audio API
If you use the Audio element to play some sound with the loop = true property, you may encounter issues.
At the end of the sound, there can be a gap before the sound starts again with the loop property
This package will help you solve this problem by using the Web Audio API.
Installation
You can install this package using the following command line tools:
Package can be added using npm:
npm install @hunine/use-sound-tsor, use pnpm:
pnpm add @hunine/use-sound-tsor, use yarn:
yarn add @hunine/use-sound-tsExample
import useSound from 'use-sound';
import rainAmbience from '../../sounds/rain.wav';
const PlayRainingButton = () => {
const { playSound } = useSound(rainAmbience);
return <button onClick={playSound}>Play</button>;
};