auric 0.0.4-alpha
auric: ^0.0.4-alpha copied to clipboard
Lavalink v4 client for Dart with multi-source music support (YouTube, Spotify, Apple Music, SoundCloud). Built from scratch with audio filters and queue management.
🎵 Auric #
Modern Lavalink v4 Client for Dart #
Stream music from 10+ platforms • Audio filters • Queue management • Pure Dart
Getting Started • Examples • Documentation • Discord
What is Auric? #
Auric is a powerful Lavalink v4 client written in pure Dart. Built from the ground up with simplicity and performance in mind, it makes creating music bots and audio applications straightforward and enjoyable.
// Get started in seconds
final auric = LavalinkClient(host: 'localhost', port: 2333, password: 'yourpass', userId: 'bot-id');
await auric.connect();
final result = await auric.loadTracks('ytsearch:never gonna give you up');
final player = auric.getPlayer('guild-id');
await player.play(result.tracks!.first);
Why Choose Auric? #
|
⚡ Simple Get a working music bot running in under 10 lines of code. No boilerplate, no complexity. |
🌍 Multi-Source Stream from YouTube, Spotify, Apple Music, SoundCloud, and 10+ other platforms seamlessly. |
🎛️ Feature-Rich Professional audio filters, advanced queue management, and real-time event streaming included. |
|
🔧 Pure Dart Zero native dependencies. Works on all platforms where Dart runs. |
📚 Well Documented Comprehensive guides, working examples, and clear API documentation. |
🚀 Production Ready Battle-tested in real Discord bots serving thousands of users. |
Quick Start #
Installation #
Add Auric to your pubspec.yaml:
dependencies:
auric: ^0.0.2-alpha
Then run:
dart pub get
Your First Music Player #
Here's a complete example that searches for a song and plays it:
import 'package:auric/auric.dart';
void main() async {
// Connect to your Lavalink server
final auric = LavalinkClient(
host: 'localhost',
port: 2333,
password: 'youshallnotpass',
userId: 'your-bot-id',
);
await auric.connect();
// Search and play a track
final result = await auric.loadTracks('ytsearch:never gonna give you up');
final track = result.tracks!.first;
final player = auric.getPlayer('guild-id');
await player.play(track);
print('Now playing: ${track.info.title}');
}
That's it. You're streaming music.
Multi-Source Music #
Auric makes it trivial to search across different platforms. Just prefix your search query:
// Search YouTube
final yt = await auric.loadTracks('ytsearch:despacito');
// Search Spotify
final sp = await auric.loadTracks('spsearch:imagine dragons');
// Search Apple Music
final am = await auric.loadTracks('amsearch:taylor swift');
// Search SoundCloud
final sc = await auric.loadTracks('scsearch:chill beats');
Or use the helper class for cleaner code:
final query = SearchQuery.parse('sp imagine dragons');
final result = await auric.loadTracks(query.toLavalinkQuery());
Supported platforms: YouTube, YouTube Music, Spotify, Apple Music, SoundCloud, Deezer, Yandex Music, Bandcamp, Twitch, Vimeo, and more.
Queue Management #
Building a playlist? Auric handles queues elegantly:
final player = auric.getPlayer('guild-id');
// Add tracks to the queue
player.addToQueue(track1);
player.addToQueue(track2);
player.addToQueue(track3);
// Play the queue
await player.play(player.queue.first);
// Skip to next track
await player.playNext();
// Shuffle the queue
player.shuffleQueue();
// Clear everything
player.clearQueue();
// Listen to queue changes
player.queueStream.listen((queue) {
print('Queue updated: ${queue.length} tracks');
});
Audio Filters #
Want to add some flavor to your music? Apply professional-grade audio effects:
final player = auric.getPlayer('guild-id');
// Nightcore (faster, higher pitch)
await player.setFilters(Timescale.nightcore().toJson());
// Vaporwave (slower, lower pitch)
await player.setFilters(Timescale.vaporwave().toJson());
// Bass boost
await player.setFilters(Equalizer.bassBoost().toJson());
// 8D audio effect
await player.setFilters(Rotation.slow().toJson());
// Karaoke mode (remove vocals)
await player.setFilters(Karaoke.preset().toJson());
// Combine multiple filters
final combined = FilterConfig(
timescale: Timescale.nightcore(),
equalizer: Equalizer.bassBoost(),
rotation: Rotation.fast(),
);
await player.setFilters(combined.toJson());
// Reset to normal
await player.clearFilters();
Real-Time Events #
Stay informed about what's happening with your player:
auric.eventStream.listen((event) {
if (event is TrackStartEvent) {
print('Started: ${event.track.info.title}');
} else if (event is TrackEndEvent) {
print('Ended: ${event.reason}');
// Auto-play next track
if (event.reason == 'finished') {
player.playNext();
}
} else if (event is TrackStuckEvent) {
print('Track stuck at ${event.thresholdMs}ms');
} else if (event is WebSocketClosedEvent) {
print('Connection lost: ${event.reason}');
}
});
Playback Control #
Full control over your audio:
final player = auric.getPlayer('guild-id');
// Basic controls
await player.pause();
await player.resume();
await player.stop();
// Volume control (0-200)
await player.setVolume(150);
// Seek to specific position
await player.seek(Duration(seconds: 30));
// Check current state
print('Position: ${player.position}');
print('Duration: ${player.currentTrack?.info.duration}');
print('Is paused: ${player.isPaused}');
Building a Discord Bot #
Auric includes a ready-to-use bot framework. Here's a complete Discord music bot in minimal code:
import 'package:auric/auric.dart';
void main() async {
final bot = EasyMusicBot(
lavalinkHost: 'localhost',
lavalinkPort: 2333,
lavalinkPassword: 'youshallnotpass',
botUserId: 'your-bot-id',
prefix: '!',
);
await bot.start();
// Integrate with your Discord library
discordClient.onMessage.listen((msg) async {
final response = await bot.handleMessage(
message: msg.content,
userId: msg.author.id,
guildId: msg.guild.id,
channelId: msg.channel.id,
);
if (response != null) {
await msg.channel.send(response);
}
});
}
This gives you 30+ commands out of the box:
- Playback:
!play,!pause,!resume,!stop,!skip - Queue:
!queue,!shuffle,!clear,!remove - Audio:
!nightcore,!bassboost,!8d,!karaoke - Controls:
!volume,!seek,!forward,!rewind - Info:
!nowplaying,!help,!sources
Lavalink Setup #
Auric requires a Lavalink server. Here's the fastest way to get one running:
Using Docker #
docker run -d \
--name lavalink \
-p 2333:2333 \
-v $(pwd)/application.yml:/opt/Lavalink/application.yml \
fredboat/lavalink:latest
Configuration (application.yml) #
server:
port: 2333
address: 0.0.0.0
lavalink:
server:
password: "youshallnotpass"
sources:
youtube: true
soundcloud: true
bufferDurationMs: 400
frameBufferDurationMs: 5000
plugins:
lavasrc:
providers:
- "ytsearch:\"%ISRC%\""
- "ytsearch:%QUERY%"
sources:
spotify: true
applemusic: true
deezer: true
yandexmusic: true
spotify: true
applemusic: true
Note: API credentials are configured in the Lavalink server's application.yml. Auric clients don't need API keys - the Lavalink server handles authentication with external services.
Examples #
Check the example/ directory for complete working examples:
- basic_usage.dart - Core features and playback control
- queue_management.dart - Advanced queue operations
- audio_filters.dart - All available audio effects
- multi_source_search.dart - Searching across platforms
- discord_bot_example.dart - Full Discord bot integration
- super_easy_bot.dart - Minimal bot using the framework
Run any example:
dart run example/basic_usage.dart
API Overview #
LavalinkClient #
The main client for connecting to Lavalink:
final auric = LavalinkClient(
host: 'localhost',
port: 2333,
password: 'youshallnotpass',
userId: 'bot-id',
);
await auric.connect(enableResuming: true);
final player = auric.getPlayer('guild-id');
await auric.disconnect();
Player #
Control playback for a specific guild/room:
// Playback
await player.play(track);
await player.pause();
await player.resume();
await player.stop();
// Queue
player.addToQueue(track);
await player.playNext();
await player.skipTo(index);
player.shuffleQueue();
player.clearQueue();
// Volume & Seeking
await player.setVolume(100);
await player.seek(Duration(seconds: 30));
// Filters
await player.setFilters(Timescale.nightcore().toJson());
await player.clearFilters();
// State
print(player.currentTrack);
print(player.position);
print(player.queue);
print(player.isPaused);
Search #
Find music from any platform:
// Direct search
final result = await auric.loadTracks('ytsearch:query');
// Using helper
final query = SearchQuery.parse('sp artist name');
final result = await auric.loadTracks(query.toLavalinkQuery());
// Check result type
if (result.tracks != null) {
print('Found ${result.tracks!.length} tracks');
} else if (result.playlist != null) {
print('Found playlist: ${result.playlist!.name}');
}
Advanced Features #
Session Resuming #
Keep playback going even if your bot restarts:
await auric.connect(
enableResuming: true,
sessionId: 'my-session-id',
);
Event Streaming #
React to player events in real-time:
auric.eventStream.listen((event) {
// Handle all event types
});
player.queueStream.listen((queue) {
// Queue updated
});
Direct REST API #
For advanced use cases, access the REST API directly:
final stats = await auric.rest.getStats();
final info = await auric.rest.getInfo();
Troubleshooting #
Connection refused
- Ensure Lavalink is running on the correct host and port
- Check firewall settings
No tracks found
- Verify the Lavalink plugins are configured (LavaSrc for Spotify, Apple Music, etc.)
- Check API credentials in
application.yml
Playback issues
- Ensure the bot has joined a voice channel before playing
- Check Lavalink logs for errors
Session resuming not working
- Use the same
sessionIdwhen reconnecting - Ensure resuming is enabled in Lavalink config
Contributing #
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
dart test) - Commit (
git commit -m 'Add amazing feature') - Push (
git push origin feature/amazing-feature) - Open a Pull Request
Please ensure your code follows Dart style guidelines and includes tests.
License #
MIT License - see LICENSE file for details.
Acknowledgments #
Auric wouldn't exist without these amazing projects:
- Lavalink - The robust audio server that powers Auric
- LavaSrc - Multi-source plugin for Lavalink
- Dart Team - For creating an excellent language and ecosystem
Links #
- GitHub Repository
- Lavalink Documentation
- Discord - Join for support and discussion
Built with care by the Auric team. Happy streaming! 🎵