A lightweight, modern, modular audio engine that provides playback, filters, queue management, events, and extensibility through plugins. Works in both Node.js and browser environments.
Version 1.0.2 represents a major stability and architecture enhancement, introducing a standardized provider system, robust plugin lifecycle, and full TypeScript support.
- π΅ Unified Audio Engine: Cross-environment abstraction using Web Audio API.
- π Advanced Queue Management: Add, remove, shuffle, jump, loop (track/queue) modes.
- ποΈ Audio Filters: Bassboost, nightcore, vaporwave, 8D rotate, pitch/speed adjustment, reverb.
- π Robust Plugin System: Extensible architecture with safe lifecycle hooks and error isolation.
- π‘ Event-Driven: Comprehensive event system for all operations.
- π Provider Registry: Standardized interface for providers (Local, YouTube, Spotify, Lavalink).
- π οΈ Developer-Friendly: Full TypeScript support, strict typings, and ESM/CJS builds.
Audify-js v1.0.2 uses a modular architecture:
- AudioEngine: The central controller orchestrating playback, queue, and events.
- ProviderRegistry: Manages source providers (e.g., resolving URLs to streams).
- Player: Handles low-level audio context and buffer management.
- Queue: Manages track list and state.
- PluginManager: Handles extensions and hooks.
For more detailed information, check out the documentation:
npm install @students-dev/audify-js<!DOCTYPE html>
<html>
<head>
<title>audify-js Demo</title>
</head>
<body>
<script type="module">
import { AudioEngine } from './dist/esm/index.js';
const engine = new AudioEngine();
engine.eventBus.on('ready', () => {
console.log('Audio engine ready!');
engine.play('https://example.com/audio.mp3');
});
engine.eventBus.on('trackStart', (track) => {
console.log('Now playing:', track.title);
});
</script>
</body>
</html>import { AudioEngine, LocalProvider } from '@students-dev/audify-js';
const engine = new AudioEngine();
// Engine automatically registers default providers (Local, YouTube)
// But you can register custom ones or configure them
engine.eventBus.on('ready', async () => {
await engine.play('./music/song.mp3');
});Providers allow audify-js to resolve and play tracks from various sources. v1.0.2 introduces a Provider Registry.
- LocalProvider: Plays local files (Node.js) or direct URLs.
- YouTubeProvider: Resolves YouTube URLs (requires
ytdl-corein real usage, mock included). - SpotifyProvider: Integrates with Spotify Web API.
- LavalinkProvider: Connects to Lavalink nodes.
const engine = new AudioEngine({
spotify: {
clientId: '...',
clientSecret: '...'
},
lavalink: {
host: 'localhost',
password: 'youshallnotpass'
}
});Create powerful extensions using the Plugin class.
import { Plugin, IAudioEngine } from '@students-dev/audify-js';
class MyLoggerPlugin extends Plugin {
constructor() {
super('logger', '1.0.0');
}
onLoad(engine: IAudioEngine) {
console.log('Plugin loaded');
}
beforePlay(track: any) {
console.log('About to play:', track.title);
}
trackEnd(track: any) {
console.log('Finished:', track.title);
}
}
// Register
const plugin = new MyLoggerPlugin();
engine.plugins.load(plugin);
engine.plugins.enable('logger');play(track?: ITrack | string): Play a track object or resolve a string (URL/ID).pause(): Pause playback.stop(): Stop playback.seek(time): Seek to time in seconds.setVolume(volume): 0.0 to 1.0.setLoopMode(mode): 'off', 'track', 'queue'.add(tracks): Add to queue.next(): Skip to next.previous(): Skip to previous.shuffle(): Shuffle queue.getProvider(name): Get a provider instance.
Access via engine.eventBus.on(event, callback).
readyplay,pause,stoptrackStart,trackEndqueueUpdateerror
- Fork the repository
- Create feature branch
- Commit changes
- Push and PR
MIT