
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
audio-hooks
Advanced tools
A React hooks library for managing audio playback with advanced controls and features.
A React hooks library for managing audio playback with advanced controls and features.
npm install audio-hooks
RepeatOne
, RepeatAll
, Shuffle
)// hooks/usePlayList.ts
import { useAudioList, AudioProvider } from 'audio-hooks/react'
export interface PlayList {
id: string
name: string
owner?: string
cover?: string
description?: string
tracks: Track[]
createdAt?: string
updatedAt?: string
duration?: number
isPublic?: boolean
tags?: string[]
}
type Track = {
name: string
artist: string
album: string
cover?: string
url: string
}
export const usePlayList = ({ tracks = [] }: PlayList) => {
const {
state,
controls,
} = useAudioList(tracks.map(({ url }) => url))
return {
state,
controls,
playingTrack: tracks[state.playingIndex],
}
}
// components/AudioPlayer.tsx
import { usePlayList } from 'hooks/usePlayList'
const playList = {
name: 'My Playlist',
tracks: [],
// ...
}
const AudioPlayer = () => {
const {
state,
controls,
playingTrack,
} = usePlayList(playList)
return (
<AudioProvider>
<div>
Playing: {state.playing ? 'Yes' : 'No'}
Current Track: {state.playingIndex + 1} of {playList.tracks.length}
Time: {state.currentTime} / {state.duration}
</div>
<div>
<button onClick={controls.play}>Play</button>
<button onClick={controls.pause}>Pause</button>
<button onClick={controls.prev}>Previous</button>
<button onClick={controls.next}>Next</button>
</div>
</AudioProvider>
)
}
useAudioList(urls: string[])
Returns an object containing the current state and controls for audio playback.
state
volume
: number
- Current volume level between 0
and 1
.playing
: boolean
- Whether audio is currently playing.duration
: number
- Total duration of current track in seconds.currentTime
: number
- Current playback position in seconds.playbackRate
: number
- Current playback speed between 0.5
and 3.0
.playingIndex
: number
- Index of currently playing track in playlist.controls
play()
: Start playing the current audio track.pause()
: Pause the current audio track.prev()
: Go to previous track based on current play mode.next()
: Skip to next track based on current play mode.setVolume(volume: number)
: Set audio volume between 0
and 1
.seek(time: number)
: Seeks to the specified time in seconds.playTrack(index: number)
: Play specific track by index.setPlaybackRate(rate: number)
: Set playback rate between 0.5
and 3.0
.nextPlayMode(mode?: PlayMode)
: Change the play mode to the next mode in the list.
type PlayMode = 'RepeatAll' | 'RepeatOne' | 'Shuffle'
setList(urls: string[])
Update the list of audio URLs.
MIT © Lee
Contributions are welcome! Please feel free to submit a Pull Request.
FAQs
A React hooks library for managing audio playback with advanced controls and features.
The npm package audio-hooks receives a total of 0 weekly downloads. As such, audio-hooks popularity was classified as not popular.
We found that audio-hooks 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.