
Security News
NIST Under Federal Audit for NVD Processing Backlog and Delays
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
@wavesurfer/react
Advanced tools
A React component and hook for wavesurfer.js.
It makes it easy to use wavesurfer from React. All of the familiar wavesurfer options become React props.
You can subscribe to various wavesurfer events also via props. Just prepend an event name with on, e.g. ready
-> onReady
. Each event callback receives a wavesurfer instance as the first argument.
With yarn:
yarn add wavesurfer.js @wavesurfer/react
With npm:
npm install wavesurfer.js @wavesurfer/react
As a component:
import WavesurferPlayer from '@wavesurfer/react'
const App = () => {
const [wavesurfer, setWavesurfer] = useState(null)
const [isPlaying, setIsPlaying] = useState(false)
const onReady = (ws) => {
setWavesurfer(ws)
setIsPlaying(false)
}
const onPlayPause = () => {
wavesurfer && wavesurfer.playPause()
}
return (
<>
<WavesurferPlayer
height={100}
waveColor="violet"
url="/my-server/audio.wav"
onReady={onReady}
onPlay={() => setIsPlaying(true)}
onPause={() => setIsPlaying(false)}
/>
<button onClick={onPlayPause}>
{isPlaying ? 'Pause' : 'Play'}
</button>
</>
)
}
Alternatively, as a hook:
import { useRef } from 'react'
import { useWavesurfer } from '@wavesurfer/react'
const App = () => {
const containerRef = useRef(null)
const { wavesurfer, isReady, isPlaying, currentTime } = useWavesurfer({
container: containerRef,
url: '/my-server/audio.ogg',
waveColor: 'purple',
height: 100,
})
const onPlayPause = () => {
wavesurfer && wavesurfer.playPause()
}
return (
<>
<div ref={containerRef} />
<button onClick={onPlayPause}>
{isPlaying ? 'Pause' : 'Play'}
</button>
</>
)
}
FAQs
React component and hook for wavesurfer.js
The npm package @wavesurfer/react receives a total of 40,014 weekly downloads. As such, @wavesurfer/react popularity was classified as popular.
We found that @wavesurfer/react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.
Security News
TypeScript Native Previews offers a 10x faster Go-based compiler, now available on npm for public testing with early editor and language support.