1.7.1 • Published 4 months ago

clicktone v1.7.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

npm GitHub package version NPM Downloads

Install

yarn add clicktone

Import

import ClickTone from 'clicktone';

Usage

ClickTone uses the Web Audio API, which supports many audio file formats: MP3, WAV, OGG, AAC and others. Note that not all browsers support these formats.

const sound = new ClickTone({
  file: './sound.mp3',
  // file: new URL('./sound.mp3', import.meta.url).href,
  volume: 0.7,
  throttle: 100,
  callback: () => { console.log('Playback ended') },
  debug: true,
});

const play = () => sound.play();

button.addEventListener('pointerdown', play);

Options

OptionTypeDefaultDescription
filestringnoneThe URL of the audio file to be played.
volumenumber1.0Volume level for the audio playback, ranging from 0.0 (mute) to 1.0 (full volume).
callback((error?: Error) => void) \| nullnullA callback function to be executed after the audio finishes playing, or if an error occurs.
throttlenumber0Minimum time (in milliseconds) between successive audio plays to prevent rapid repeat plays.
debugbooleanfalseIf true, debug information and errors will be logged to the console.

License

clicktone is released under MIT license.

1.7.1

4 months ago

1.7.0

5 months ago

1.6.0

5 months ago

1.5.4

1 year ago

1.5.3

1 year ago

1.5.2

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

2 years ago