Methods | Android | IOS | Web | |
---|---|---|---|---|
querySongs |
✔️ |
✔️ |
✔️ |
|
queryAlbums |
✔️ |
✔️ |
✔️ |
|
queryArtists |
✔️ |
✔️ |
✔️ |
|
queryPlaylists |
✔️ |
✔️ |
❌ |
|
queryGenres |
✔️ |
✔️ |
✔️ |
|
queryAudiosFrom |
✔️ |
✔️ |
✔️ |
|
queryWithFilters |
✔️ |
✔️ |
✔️ |
|
queryArtwork |
✔️ |
✔️ |
✔️ |
|
createPlaylist |
✔️ |
✔️ |
❌ |
|
removePlaylist |
✔️ |
❌ |
❌ |
|
addToPlaylist |
✔️ |
✔️ |
❌ |
|
removeFromPlaylist |
✔️ |
❌ |
❌ |
|
renamePlaylist |
✔️ |
❌ |
❌ |
|
moveItemTo |
✔️ |
❌ |
❌ |
|
checkAndRequest |
✔️ |
✔️ |
❌ |
|
permissionsRequest |
✔️ |
✔️ |
❌ |
|
permissionsStatus |
✔️ |
✔️ |
❌ |
|
queryDeviceInfo |
✔️ |
✔️ |
✔️ |
|
scanMedia |
✔️ |
❌ |
❌ |
✔️ -> Supported
❌ -> Not Supported
See all platforms methods support
Add the following code to your pubspec.yaml
:
dependencies:
on_audio_query: ^2.9.0
To use this plugin add the following code to your AndroidManifest.xml
<manifest>
<!-- Android 12 or below -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<!-- Android 13 or greater -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
</manifest>
To use this plugin add the following code to your Info.plist
<dict>
<key>NSAppleMusicUsageDescription</key>
<string>$(PROJECT_NAME) requires access to media library</string>
</dict>
READ
and WRITE
permission requestkeys
[Search].All types of methods on this plugin:
Widget someOtherName() async {
return QueryArtworkWidget(
id: <audioId>,
type: ArtworkType.AUDIO,
);
}
See more: QueryArtworkWidget
final OnAudioQuery _audioQuery = OnAudioQuery();
someName() async {
// Query Audios
List<AudioModel> audios = await _audioQuery.queryAudios();
// Query Albums
List<AlbumModel> albums = await _audioQuery.queryAlbums();
}
You'll use this method when updating a media from storage. This method will update the media 'state' and
Android MediaStore
will be able to know this 'state'.
someName() async {
OnAudioQuery _audioQuery = OnAudioQuery();
File file = File('path');
try {
if (file.existsSync()) {
file.deleteSync();
_audioQuery.scanMedia(file.path); // Scan the media 'path'
}
} catch (e) {
debugPrint('$e');
}
}
someName() async {
// DEFAULT: ArtworkFormat.JPEG, 200 and false
Uint8List something = await _audioQuery.queryArtwork(
<audioId>,
ArtworkType.AUDIO,
...,
);
}
Or you can use a basic and custom Widget. See example QueryArtworkWidget
Songs | Albums | Playlists | Artists |