zeaker
v2.0.2
Published
Node.js Lossless Audio Player (PortAudio + FFmpeg)
Downloads
38
Readme
Zeaker
Node.js Lossless Audio Player (PortAudio + FFmpeg)
Zeaker is a high-fidelity, cross-platform audio player for Node.js, supporting gapless playback, bit-perfect output, advanced playlist management, and robust device selection. Powered by native PortAudio bindings and FFmpeg, Zeaker delivers uncompromising lossless audio playback for desktop and server environments.
Features
- Lossless audio playback (WAV, FLAC, ALAC, AIFF, etc.)
- Gapless playback and crossfade transitions
- Bit-perfect mode for audiophile output
- Advanced playlist management (shuffle, repeat, navigation)
- Device selection (WASAPI, ASIO, CoreAudio, ALSA, etc.)
- Streaming support (HTTP/HTTPS)
- Volume control, seeking, and metadata extraction
- Robust error handling and event-driven API
Installation
npm i zeaker- Requires Node.js 16+
- FFmpeg and PortAudio are bundled for major platforms (Windows, macOS, Linux)
Usage
Basic Playback
import { AudioPlayer } from "zeaker";
const player = new AudioPlayer();
player.on("play", (track) => console.log("Now playing:", track));
player.on("error", (err) => console.error("Playback error:", err));
await player.play("track.flac");Playlist Playback
const playlist = ["song1.flac", "song2.wav", "song3.aac"];
await player.playPlaylist(playlist);Device Selection
const devices = await AudioPlayer.listOutputDevices();
console.log(devices);
await player.setOutputDevice(devices[0].index); // Select first output deviceStreaming Audio
await player.playStream("https://example.com/stream.mp3");Advanced: Gapless & Crossfade
// Enable gapless playback for next track
await player.playGapless("nextTrack.flac");
// Crossfade to next track (3s duration)
await player.crossfadeTo("nextTrack.flac", 3);Effects & Bit-Perfect Mode
player.getManagers().effects.setBitPerfect(true); // Enable bit-perfect output
player.getManagers().effects.setCrossfadeDuration(5); // 5s crossfadeVolume, Pause, Resume, Seek
await player.setVolume(0.5); // 50% volume
await player.pause();
await player.resume();
await player.seek(60); // Seek to 1:00Metadata Extraction
const metadata = await player.getMetadata();
console.log(metadata); // { title, artist, album, duration, ... }Supported Formats
- WAV, FLAC, ALAC, AIFF, MP3, AAC, M4A, OGG, MP4, and more (via FFmpeg)
Error Handling
Zeaker provides robust error handling and user-friendly messages. Listen for the error event on the player instance, or use the exported handleError utility for custom handling.
API Reference
Zeaker exposes a modular, event-driven API. Below is a summary of the main modules and their key methods. For full details, see the source JSDoc or DOCUMENTATION.md.
Modules
- AudioPlayer — Main playback API (play, pause, resume, stop, seek, volume, metadata, playlist, gapless, crossfade, streaming, device selection)
- DeviceManager — Audio device discovery, selection, and validation
- PlaylistManager — Playlist operations (load, shuffle, repeat, navigation)
- AudioEffects — Advanced effects: gapless, crossfade, bit-perfect mode
- StreamManager — HTTP/HTTPS streaming with buffering and reconnection
- AudioUtils — Audio processing and format utilities
- ErrorHandler — Centralized error handling utilities
- FFmpegUtils — FFmpeg-related utilities for audio processing
Key Classes & Methods
AudioPlayer
play(filePath, [startPosition])— Play an audio filepause()/resume()/stop()— Playback controlsseek(positionSeconds)— Seek within tracksetVolume(level)/getVolume()— Volume controlgetMetadata()— Extract metadata from current trackgetDuration()— Get track durationplayPlaylist(playlist)— Play a playlistskip()/previous()— Playlist navigationsetPlaylistShuffle([enable])— Shuffle modesetPlaylistRepeat(mode)— Repeat modeplayGapless(nextTrack)— Enable gapless playbackcrossfadeTo(nextTrack, [duration])— Crossfade to next trackplayStream(url, [options])— Play from streaming sourcesetOutputDevice(deviceIndex)— Select output devicesetBitPerfect(options)— Enable/disable bit-perfect modeonVisualization(callback)— PCM visualizationsetBufferSize(frames)— Set buffer sizesetCrossfadeDuration(duration)/setCrossfadeCurve(curve)— Crossfade configgetStatus()— Playback statusgetManagers()— Access advanced managersgetCurrentTime()— Elapsed playback timelistOutputDevices()(static) — List output devicestestSineWave()(static) — Test output with sine wave
DeviceManager
listOutputDevices()— List available output devicessetOutputDevice(deviceIndex)— Select output devicegetCurrentDevice()— Get current devicegetDefaultDevice()— Get default devicefindDeviceByName(deviceName, [exactMatch])— Find device by namevalidateDeviceCapabilities(device, requirements)— Validate device for playback
PlaylistManager
loadPlaylist(playlist)— Load a new playlistsetPlaylistShuffle([enable])— Shuffle modesetPlaylistRepeat(mode)— Repeat modegetPlaylistCopy()— Get a copy of the playlist
AudioEffects
setBitPerfect(options)— Enable/disable bit-perfect modeisBitPerfectMode()— Check bit-perfect statussetCrossfadeDuration(duration)/setCrossfadeCurve(curve)— Crossfade configgetCrossfadeConfig()— Get crossfade configprebufferNextTrack(nextTrack, ffmpegPath, [audioFormat])— Pre-buffer for gaplesscreateCrossfade(currentBuffers, nextBuffers, sampleRate, channels, [duration])— Create crossfade effectwaitForGaplessReady([timeoutMs])— Wait for gapless readygetGaplessBuffers()— Get gapless bufferscleanupGapless()— Clean up gapless resourcesgetEffectAvailability()— Check effect availabilityvalidateEffectAvailability(effectName)— Validate effect usagegetConfiguration()— Get effects config
StreamManager, AudioUtils, ErrorHandler, FFmpegUtils
- See DOCUMENTATION.md for details on streaming, audio utilities, error handling, and FFmpeg helpers.
Contributing
Pull requests and issues are welcome! Please see CONTRIBUTING.md for guidelines.
License
MIT © zevinDev
