![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@cher-ami/audio-manager
Advanced tools
Readme
A simple web audio manager for the browser.
npm install @cher-ami/audio-manager
Create new AudioManager instance:
import { AudioManager } from "@cher-ami/audio-manager"
const sound = new AudioManager("sound.mp3")
sound.play()
sound.pause()
sound.stop()
sound.replay()
sound.mute()
sound.unmute()
sound.enableLoop()
sound.disableLoop()
sound.pan()
sound.fade()
sound.fadeIn()
sound.fadeOut()
sound.destroy()
Multiples instances can be created together:
import { AudioManager } from "@cher-ami/audio-manager"
const sound1 = new AudioManager("sound.mp3")
const sound2 = new AudioManager("sound.mp3")
sound1.play()
sound2.play()
// ...
AudioManager(audioFileUrl: string, options: {
volume?: number;
loop?: boolean;
})
play():Promise<void>
Play the sound.
// await sound is loaded before playing it and continue
await sound.play()
pause(): void
Pause the sound.
sound.pause()
stop(): void
Stop the sound. It will be reset to the beginning.
sound.stop()
replay(): void
Will simply stop and play the sound.
sound.replay()
mute(): void
Mute the sound.
sound.mute()
unmute(): void
Unmute the sound if he is muted.
sound.unmute()
enableLoop(): void
During the sound is playing, enable looping on it.
sound.enableLoop()
disableLoop(): void
During the sound is playing, disable looping on it.
sound.disableLoop()
pan(vPan: number): void
Used to place the sound on a device supporting stereo sound. If using -1 to 1 range. -1 would be far left & 1 far right.
sound.pan(-1) // left
sound.pan(0) // center
sound.pan(1) // right
fade(from: number, to: number, duration = 1, ease = "none"): Promise<any>
Process fade between 2 points:
from
1 = 100%, 0 = 0%to
1 = 100%, 0 = 0%duration
: default is 1
ease
: default is none
, this is gsap easing string.// fade from 0% to 60% of the volume
this.fade(0, 0.6)
// also you can wait for the fade to finish
await this.fade(0, 0.6)
// ... do sothing after fade
fadeIn(duration = 1, ease = "none"): Promise<any>
FadeIn from the current volum to 100%.
this.fadeIn()
// or
await this.fadeIn()
fadeOut(duration = 1, ease = "none"): Promise<any>
FadeOut from the current volum to 0%.
this.fadeOut()
// or
await this.fadeOut()
destroy(): void
Destroy current instance
this.destroy()
It's possible to mute all the paying sounds with global event emitter.
import { MUTE_AUDIO_SIGNAL } from "@cher-ami/audio-manager"
// mute all sounds
MUTE_AUDIO_SIGNAL.dispatch(true)
// unmute all sounds
MUTE_AUDIO_SIGNAL.dispatch(false)
Audio manager come with react hooks to use it in react components.
const App = () => {
// create audio manager instance with useAudio
const sound = useAudio("audio.mp3", { loop: true, volume: 0.5 })
// use API in handlers
return (
<div>
<button onClick={sound.play}>Play</button>
<button onClick={sound.pause}>Pause</button>
</div>
)
}
Mute all sounds with useMuteAllAudio
const [isMuted, setIsMuted] = useMuteAllAudio()
useEffect(() => {
// do something when isMuted state change
}, [isMuted])
// use API in handlers
return (
<div>
<button onClick={setIsMuted(true)}>mute</button>
<button onClick={setIsMuted(false)}>unmute</button>
</div>
)
Start example
npm run dev:example
cher-ami
FAQs
A simple web audio manager
We found that @cher-ami/audio-manager demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.