1
+ <div align =center >
2
+
1
3
# on_audio_query
2
4
[ ![ Pub.dev] ( https://img.shields.io/pub/v/on_audio_query?color=9cf&label=Pub.dev&style=flat-square )] ( https://pub.dev/packages/on_audio_query )
3
5
[ ![ Platforms] ( https://img.shields.io/badge/Platforms-Android%20%7C%20IOS%20%7C%20Web-9cf?&style=flat-square )] ( )
4
6
[ ![ Languages] ( https://img.shields.io/badge/Languages-Dart%20%7C%20Kotlin%20%7C%20Swift-9cf?&style=flat-square )] ( )
5
7
6
8
` on_audio_query ` is a [ Flutter] ( https://flutter.dev/ ) Plugin used to query audios/songs 🎶 infos [ title, artist, album, etc..] from device storage. <br >
7
9
8
- ## Help:
9
-
10
10
** Any problem? [ Issues] ( https://github.com/LucJosin/on_audio_query/issues ) ** <br >
11
11
** Any suggestion? [ Pull request] ( https://github.com/LucJosin/on_audio_query/pulls ) **
12
12
13
- ### Extensions:
14
-
15
- * [ on_audio_edit] ( https://github.com/LucJosin/on_audio_edit ) - Used to edit audio metadata.
16
- * [ on_audio_room] ( https://github.com/LucJosin/on_audio_room ) - Used to store audio [ Favorites, Most Played, etc..] .
17
-
18
- ### Translations:
19
-
20
- NOTE: Feel free to help with readme translations
21
-
22
- * [ English] ( https://github.com/LucJosin/on_audio_query/blob/main/on_audio_query/README.md )
23
- * [ Portuguese] ( https://github.com/LucJosin/on_audio_query/blob/main/on_audio_query/README.pt-BR.md )
13
+ </div >
24
14
25
15
### Topics:
26
16
27
- * [ How to Install ] ( #how-to-install )
17
+ * [ Installation ] ( #installation )
28
18
* [ Platforms] ( #platforms )
29
- * [ How to use ] ( #how-to-use )
19
+ * [ Overview ] ( #overview )
30
20
* [ Examples] ( #examples )
31
21
* [ Gif Examples] ( #gif-examples )
32
22
* [ License] ( #license )
@@ -60,30 +50,44 @@ NOTE: Feel free to help with readme translations
60
50
61
51
** [ See all platforms methods support] ( https://github.com/LucJosin/on_audio_query/blob/main/on_audio_query/PLATFORMS.md ) **
62
52
63
- ## How to Install:
53
+ ## Installation:
54
+
64
55
Add the following code to your ` pubspec.yaml ` :
65
56
``` yaml
66
57
dependencies :
67
- on_audio_query : ^2.6 .0
58
+ on_audio_query : ^2.7 .0
68
59
` ` `
69
60
70
61
### Request Permission:
62
+
71
63
#### Android:
72
- To use this plugin add the following code to your ` AndroidManifest.xml`
64
+ To use this plugin add the following code to your [ AndroidManifest.xml](https://github.com/LucJosin/on_audio_query/blob/main/on_audio_query/example/android/app/src/main/AndroidManifest.xml)
73
65
` ` ` xml
74
- <manifest> ...
75
-
76
- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/ >
66
+ <manifest>
67
+
68
+ <!-- Android 12 or below -- >
77
69
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
70
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
71
+
72
+ <!-- Android 13 or greater -->
73
+ <uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
74
+ <uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
75
+ <uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
78
76
79
77
</manifest>
80
78
```
81
79
82
80
#### IOS:
83
- To use this plugin add the following code to your `Info.plist`
84
- ```
81
+ To use this plugin add the following code to your [ Info.plist] ( https://github.com/LucJosin/on_audio_query/blob/main/on_audio_query/example/ios/Runner/Info.plist )
82
+ ``` plist
83
+ <dict>
84
+ ...
85
+
85
86
<key>NSAppleMusicUsageDescription</key>
86
- <string>..Add a reason..</string>
87
+ <string>$(PROJECT_NAME) requires access to media library</string>
88
+
89
+ ...
90
+ </dict>
87
91
```
88
92
89
93
#### Web:
@@ -113,136 +117,54 @@ Since Web Browsers **don't** offer direct access to their user's `file system`,
113
117
* Add/Remove/Move specific audios to playlists.
114
118
* Specific sort types for all query methods.
115
119
116
- ## TODO :
120
+ ## Overview :
117
121
118
- * Add better performance for all plugin.
119
- * Add support to Windows/MacOs/Linux.
120
- * Option to remove songs.
121
- * Fix bugs.
122
-
123
- ## How to use:
124
-
125
- ``` dart
126
- OnAudioQuery() // The main method to start using the plugin.
127
- ```
128
122
All types of methods on this plugin:
129
123
130
- ### Query methods
131
-
132
- | Methods | Parameters | Return |
133
- | --------------| -----------------| -----------------|
134
- | [ ` querySongs ` ] ( #querysongs ) | ` (SortType, OrderType, UriType, RequestPermission) ` | ` List<SongModel> ` | <br >
135
- | [ ` queryAlbums ` ] ( #queryalbums ) | ` (SortType, OrderType, UriType, RequestPermission) ` | ` List<AlbumModel> ` | <br >
136
- | [ ` queryArtists ` ] ( #queryartists ) | ` (SortType, OrderType, UriType, RequestPermission) ` | ` List<ArtistModel> ` | <br >
137
- | [ ` queryPlaylists ` ] ( #queryplaylists ) | ` (SortType, OrderType, UriType, RequestPermission) ` | ` List<PlaylistModel> ` | <br >
138
- | [ ` queryGenres ` ] ( #querygenres ) | ` (SortType, OrderType, UriType, RequestPermission) ` | ` List<GenreModel> ` | <br >
139
- | [ ` queryAudiosFrom ` ] ( #queryaudiosfrom ) | ` (Type, Where, RequestPermission) ` | ` List<SongModel> ` | <br >
140
- | [ ` queryWithFilters ` ] ( #querywithfilters ) | ` (ArgsVal, WithFiltersType, Args, RequestPermission) ` | ` List<dynamic> ` | <br >
141
- | [ ` queryArtwork ` ] ( #queryArtwork ) | ` (Id, Type, Format, Size, RequestPermission) ` | ` Uint8List? ` | <br >
142
-
143
- ### Playlist methods
144
-
145
- | Methods | Parameters | Return |
146
- | --------------| -----------------| -----------------|
147
- | [ ` createPlaylist ` ] ( ) | ` (PlaylistName, RequestPermission) ` | ` bool ` | <br >
148
- | [ ` removePlaylist ` ] ( ) | ` (PlaylistId, RequestPermission) ` | ` bool ` | <br >
149
- | [ ` addToPlaylist ` ] ( ) | ** [ BG] ** ` (PlaylistId, AudioId, RequestPermission) ` | ` bool ` | <br >
150
- | [ ` removeFromPlaylist ` ] ( ) | ` (PlaylistId, AudioId, RequestPermission) ` | ` bool ` | <br >
151
- | [ ` renamePlaylist ` ] ( ) | ` (PlaylistId, NewName, RequestPermission) ` | ` bool ` | <br >
152
- | [ ` moveItemTo ` ] ( ) | ** [ NT] ** ` (PlaylistId, From, To, RequestPermission) ` | ` bool ` | <br >
153
-
154
- ### Permissions/Device methods
155
-
156
- | Methods | Parameters | Return |
157
- | --------------| -----------------| -----------------|
158
- | [ ` permissionsRequest ` ] ( ) | ` (retryRequest) ` | ` bool ` | <br >
159
- | [ ` permissionsStatus ` ] ( ) | | ` bool ` | <br >
160
- | [ ` queryDeviceInfo ` ] ( ) | | ` DeviceModel ` | <br >
161
-
162
- ### Others methods
163
- | Methods | Parameters | Return |
164
- | --------------| -----------------| -----------------|
165
- | [ ` scanMedia ` ] ( #scanmedia ) | ` (Path) ` | ` bool ` | <br >
166
-
167
124
### Artwork Widget
168
125
169
126
``` dart
170
127
Widget someOtherName() async {
171
128
return QueryArtworkWidget(
172
- id: SongId,
129
+ id: <audioId>,
173
130
type: ArtworkType.AUDIO,
174
131
);
175
132
}
176
133
```
177
134
178
135
** See more: [ QueryArtworkWidget] ( https://pub.dev/documentation/on_audio_query/latest/on_audio_query/QueryArtworkWidget-class.html ) **
179
136
180
- ### Abbreviations
181
-
182
- ** [ NT] ** -> Need Tests <br >
183
- ** [ BG] ** -> Bug on Android 10/Q
184
-
185
137
## Examples:
186
138
187
139
#### OnAudioQuery
188
- ``` dart
189
- final OnAudioQuery _audioQuery = OnAudioQuery();
190
- ```
191
140
192
- #### querySongs
193
141
``` dart
194
- someName() async {
195
- // DEFAULT:
196
- // SongSortType.TITLE,
197
- // OrderType.ASC_OR_SMALLER,
198
- // UriType.EXTERNAL,
199
- List<SongModel> something = await _audioQuery.querySongs();
200
- }
142
+ final OnAudioQuery _audioQuery = OnAudioQuery();
201
143
```
202
144
203
- #### queryAlbums
204
- ``` dart
205
- someName() async {
206
- // DEFAULT:
207
- // AlbumSortType.ALBUM,
208
- // OrderType.ASC_OR_SMALLER
209
- List<AlbumModel> something = await _audioQuery.queryAlbums();
210
- }
211
- ```
145
+ #### Query methods:
212
146
213
- #### queryArtists
214
- ``` dart
215
- someName() async {
216
- // DEFAULT:
217
- // ArtistSortType.ARTIST,
218
- // OrderType.ASC_OR_SMALLER
219
- List<ArtistModel> something = await _audioQuery.queryArtists();
220
- }
221
- ```
147
+ - queryAudios();
148
+ - queryAlbums();
149
+ - queryArtists();
150
+ - queryPlaylists();
151
+ - queryGenres().
222
152
223
- #### queryPlaylists
224
153
``` dart
225
154
someName() async {
226
- // DEFAULT:
227
- // PlaylistSortType.NAME,
228
- // OrderType.ASC_OR_SMALLER
229
- List<PlaylistModel> something = await _audioQuery.queryPlaylists();
230
- }
231
- ```
155
+ // Query Audios
156
+ List<AudioModel> audios = await _audioQuery.queryAudios();
232
157
233
- #### queryGenres
234
- ``` dart
235
- someName() async {
236
- // DEFAULT:
237
- // GenreSortType.NAME,
238
- // OrderType.ASC_OR_SMALLER
239
- List<GenreModel> something = await _audioQuery.queryGenres();
158
+ // Query Albums
159
+ List<AlbumModel> albums = await _audioQuery.queryAlbums();
240
160
}
241
161
```
242
162
243
163
#### scanMedia
164
+
244
165
You'll use this method when updating a media from storage. This method will update the media 'state' and
245
166
Android ` MediaStore ` will be able to know this 'state'.
167
+
246
168
``` dart
247
169
someName() async {
248
170
OnAudioQuery _audioQuery = OnAudioQuery();
@@ -259,12 +181,13 @@ Android `MediaStore` will be able to know this 'state'.
259
181
```
260
182
261
183
#### queryArtwork
184
+
262
185
``` dart
263
186
someName() async {
264
187
// DEFAULT: ArtworkFormat.JPEG, 200 and false
265
188
Uint8List something = await _audioQuery.queryArtwork(
266
- SongId,
267
- ArtworkType.AUDIO,
189
+ <audioId>,
190
+ ArtworkType.AUDIO,
268
191
...,
269
192
);
270
193
}
@@ -273,71 +196,6 @@ Android `MediaStore` will be able to know this 'state'.
273
196
Or you can use a basic and custom Widget.
274
197
** See example [ QueryArtworkWidget] ( #artwork-widget ) **
275
198
276
- #### queryAudiosFrom
277
- You can use this method to 'query' the songs from any section(Album, Artist, Playlist or Genre).
278
- ``` dart
279
- someName() async {
280
- List<SongModel> something = await _audioQuery.queryAudiosFrom(
281
- AudiosFromType.ALBUM_ID,
282
- albumId,
283
- // You can also define a sortType
284
- sortType: SongSortType.TITLE, // Default
285
- orderType: OrderType.ASC_OR_SMALLER, // Default
286
- );
287
- }
288
- ```
289
-
290
- #### queryWithFilters
291
- ``` dart
292
- someName() async {
293
- // Here we'll search for a [song](WithFiltersType.AUDIOS) using his
294
- // [artist](AudiosArgs.ARTIST)
295
- List<dynamic> something = await _audioQuery.queryWithFilters(
296
- // The [text] to search
297
- "Sam Smith",
298
- // The type of search you want.
299
- // All types:
300
- // * WithFiltersType.AUDIOS
301
- // * WithFiltersType.ALBUMS
302
- // * WithFiltersType.PLAYLISTS
303
- // * WithFiltersType.ARTISTS
304
- // * WithFiltersType.GENRES
305
- WithFiltersType.AUDIOS,
306
- // This method has [args] as parameter. With this value you can create
307
- // a more 'advanced' search.
308
- args: AudiosArgs.ARTIST,
309
- );
310
-
311
- // Other example:
312
-
313
- // Here we'll search for a [song](WithFiltersType.AUDIOS) using his
314
- // [album](AudiosArgs.ALBUM)
315
- List<dynamic> something = await _audioQuery.queryWithFilters(
316
- // The [text] to search
317
- "In the Lonely Hour",
318
- // The type of search you want.
319
- // All types:
320
- // * WithFiltersType.AUDIOS
321
- // * WithFiltersType.ALBUMS
322
- // * WithFiltersType.PLAYLISTS
323
- // * WithFiltersType.ARTISTS
324
- // * WithFiltersType.GENRES
325
- WithFiltersType.AUDIOS,
326
- // This method has [args] as parameter. With this value you can create
327
- // a more 'advanced' search.
328
- args: AudiosArgs.ALBUM,
329
- );
330
-
331
- // After getting the result from [queryWithFilters], convert this list using:
332
- List<TypeModel> convertedList = something.toTypeModel();
333
-
334
- // Example:
335
- List<SongModel> convertedSongs = something.toSongModel();
336
- }
337
- ```
338
-
339
- ArgsTypes: [ AudiosArgs] ( https://pub.dev/documentation/on_audio_query_platform_interface/latest/on_audio_query_helper/AudiosArgs-class.html ) , [ AlbumsArgs] ( https://pub.dev/documentation/on_audio_query_platform_interface/latest/on_audio_query_helper/AlbumsArgs-class.html ) , [ PlaylistsArgs] ( https://pub.dev/documentation/on_audio_query_platform_interface/latest/on_audio_query_helper/PlaylistsArgs-class.html ) , [ ArtistsArgs] ( https://pub.dev/documentation/on_audio_query_platform_interface/latest/on_audio_query_helper/ArtistsArgs-class.html ) and [ GenresArgs] ( https://pub.dev/documentation/on_audio_query_platform_interface/latest/on_audio_query_helper/GenresArgs-class.html )
340
-
341
199
## Gif Examples:
342
200
| <img src =" https://user-images.githubusercontent.com/76869974/129740857-33f38b27-06a3-4959-bb31-2ae97d6b66ff.gif " /> | <img src =" https://user-images.githubusercontent.com/76869974/129741012-1215b292-d700-466f-9c41-552df0ad5e89.gif " /> | <img src =" https://user-images.githubusercontent.com/76869974/129741188-e6803432-24d7-4e39-bfde-cc6765e13663.gif " /> | <img src =" https://user-images.githubusercontent.com/76869974/129741151-b820edc9-ddbf-4446-b67a-6e254cb5a46d.gif " /> |
343
201
| :---:| :---:| :---:| :---:|
0 commit comments