Audio file discovery and metadata reading for Sono.
Step 1. Add this to your pubspec.yaml in the dependencies section:
sono_query:
git:
url: https://github.com/appsono/sono_query.git
ref: <current_tag>Step 2. Add the import and start querying:
import 'package:sono_query/sono_query.dart';
// Get all songs at once
final songs = await SonoQuery.getSongs();
// Or stream in batches, useful for large libraries (recommended)
await for (final song in SonoQuery.getSongsStream()) {
print(song);
}Both getSongs and getSongsStream accept an onError callback for files that fail metadata reading. Failed files are skipped, scanning continues:
final songs = await SonoQuery.getSongs(
onError: (path, error) => print('Failed to read $path: $error'),
);final cover = await SonoQuery.getCover('/path/to/song.mp3');
// Returns Uint8List? (JPEG, PNG, or WebP bytes)Of course all of this won't work without permission
Add to your AndroidManifest.xml:
<!-- Android 13+ (API 33) -->
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<!-- Android 12 and below -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />Must be requested at runtime before calling SonoQuery.getSongs().
Without it, the query WILL return an empty list.
Add to your Info.plist if scanning outside the app sandbox:
<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>It scans the app's Documents and Music directories by default. Files must be added to these directories through the Files app or iTunes file sharing.
No special permissions needed. Scans ~/Music (Linux) or %USERPROFILE%\Music (Windows).
| Platform | Method | Metadata source |
|---|---|---|
| Android | MediaStore | MediaStore |
| iOS | FileManager | audio_metadata_reader |
| Linux | dart:io | audio_metadata_reader |
| Windows | dart:io | audio_metadata_reader |
MP3, M4A, FLAC, OGG, Opus, WAV
Metadata reading by audio_metadata_reader
MIT