Skip to content
This repository was archived by the owner on Aug 16, 2025. It is now read-only.

Commit 20d99ac

Browse files
committed
Update 2.6.0 - Fixed #67
1 parent 7452b78 commit 20d99ac

File tree

11 files changed

+94
-19
lines changed

11 files changed

+94
-19
lines changed

on_audio_query/CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
## [2.6.0] - [02.01.2022]
2+
### Features
3+
- **[Added]** `[scanMedia]` method that will scan the given path and update the `[Android]` MediaStore.
4+
5+
### Fixes
6+
- **[Fixed]** media showing when calling `[querySongs]` even after deleting with `[dart:io]`. - [#67](https://github.com/LucJosin/on_audio_query/issues/67)
7+
8+
### Changes
9+
- **[Updated]** some required packages.
10+
11+
### Documentation
12+
- Updated `README` documentation.
13+
- Updated `DEPRECATED` documentation.
14+
- Updated `PLATFORMS` documentation.
15+
- Updated some `broken` links.
16+
117
## [2.5.3+1] - [01.20.2022]
218
### Changes
319
- **[Updated]** all Github links.

on_audio_query/DEPRECATED.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## [2.5.0] - [10.15.2021] -> [X.X.X] - [XX.XX.XXXX]
1+
## [2.5.0] - [10.15.2021] -> [2.6.0] - [02.01.2022]
22
### Deprecated
33
- `[albumId]` from `[AlbumModel]`.
44
- Use `[id]` instead.

on_audio_query/PLATFORMS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Here you'll see a extra information about every method/type etc..
5454
| `permissionsRequest` | `✔️` | `✔️` | `` | <br>
5555
| `permissionsStatus` | `✔️` | `✔️` | `` | <br>
5656
| `queryDeviceInfo` | `✔️` | `✔️` | `✔️` | <br>
57+
| `scanMedia` | `✔️` | `` | `` | <br>
5758

5859
## SortTypes
5960

on_audio_query/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ NOTE: Feel free to help with readme translations
5353
| `permissionsRequest` | `✔️` | `✔️` | `` | <br>
5454
| `permissionsStatus` | `✔️` | `✔️` | `` | <br>
5555
| `queryDeviceInfo` | `✔️` | `✔️` | `✔️` | <br>
56+
| `scanMedia` | `✔️` | `` | `` | <br>
5657

5758
✔️ -> Supported <br>
5859
❌ -> Not Supported <br>
@@ -63,7 +64,7 @@ NOTE: Feel free to help with readme translations
6364
Add the following code to your `pubspec.yaml`:
6465
```yaml
6566
dependencies:
66-
on_audio_query: ^2.5.3+1
67+
on_audio_query: ^2.6.0
6768
```
6869
6970
### Request Permission:

on_audio_query/README.pt-BR.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ NOTE: Fique à vontade para ajudar nas traduções
5353
| `permissionsRequest` | `✔️` | `✔️` | `` | <br>
5454
| `permissionsStatus` | `✔️` | `✔️` | `` | <br>
5555
| `queryDeviceInfo` | `✔️` | `✔️` | `✔️` | <br>
56+
| `scanMedia` | `✔️` | `` | `` | <br>
5657

5758
✔️ -> Tem suporte <br>
5859
❌ -> Não tem suporte <br>
@@ -63,7 +64,7 @@ NOTE: Fique à vontade para ajudar nas traduções
6364
Adicione o seguinte codigo para seu `pubspec.yaml`:
6465
```yaml
6566
dependencies:
66-
on_audio_query: ^2.5.3
67+
on_audio_query: ^2.6.0
6768
```
6869
6970
#### Solicitar Permissões:

on_audio_query/android/src/main/kotlin/com/lucasjosino/on_audio_query/OnAudioQueryPlugin.kt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
=============
33
Author: Lucas Josino
44
Github: https://github.com/LucJosin
5-
Website: https://lucasjosino.com/
5+
Website: https://www.lucasjosino.com/
66
=============
77
Plugin/Id: on_audio_query#0
88
Homepage: https://github.com/LucJosin/on_audio_query
99
Pub: https://pub.dev/packages/on_audio_query
10-
License: https://github.com/LucJosin/on_audio_query/blob/main/LICENSE
10+
License: https://github.com/LucJosin/on_audio_query/blob/main/on_audio_query/LICENSE
1111
Copyright: © 2021, Lucas Josino. All rights reserved.
1212
=============
1313
*/
@@ -18,6 +18,7 @@ import android.Manifest
1818
import android.app.Activity
1919
import android.content.Context
2020
import android.content.pm.PackageManager
21+
import android.media.MediaScannerConnection
2122
import androidx.annotation.NonNull
2223
import androidx.core.app.ActivityCompat
2324
import androidx.core.content.ContextCompat
@@ -79,6 +80,20 @@ class OnAudioQueryPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
7980
// Device information
8081
"queryDeviceInfo" -> queryDeviceInfo(result)
8182

83+
// This method will scan the given path to update the 'state'.
84+
// When deleting a file using 'dart:io', call this method to update the file 'state'.
85+
"scan" -> {
86+
val sPath: String? = call.argument<String>("path")
87+
88+
// Check if the given file is null or empty.
89+
if (sPath == null || sPath.isEmpty()) result.success(false)
90+
91+
// Scan and return
92+
MediaScannerConnection.scanFile(pContext, arrayOf(sPath), null) { _, _ ->
93+
result.success(true)
94+
}
95+
}
96+
8297
// All others methods
8398
else -> onAudioController.onAudioController()
8499
}

on_audio_query/example/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
=============
33
Author: Lucas Josino
44
Github: https://github.com/LucJosin
5-
Website: https://lucasjosino.com/
5+
Website: https://www.lucasjosino.com/
66
=============
77
Plugin/Id: on_audio_query#0
88
Homepage: https://github.com/LucJosin/on_audio_query
99
Pub: https://pub.dev/packages/on_audio_query
10-
License: https://github.com/LucJosin/on_audio_query/blob/main/LICENSE
10+
License: https://github.com/LucJosin/on_audio_query/blob/main/on_audio_query/LICENSE
1111
Copyright: © 2021, Lucas Josino. All rights reserved.
1212
=============
1313
*/

on_audio_query/lib/details/on_audio_query_controller.dart

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
=============
33
Author: Lucas Josino
44
Github: https://github.com/LucJosin
5-
Website: https://lucasjosino.com/
5+
Website: https://www.lucasjosino.com/
66
=============
77
Plugin/Id: on_audio_query#0
88
Homepage: https://github.com/LucJosin/on_audio_query
99
Pub: https://pub.dev/packages/on_audio_query
10-
License: https://github.com/LucJosin/on_audio_query/blob/main/LICENSE
10+
License: https://github.com/LucJosin/on_audio_query/blob/main/on_audio_query/LICENSE
1111
Copyright: © 2021, Lucas Josino. All rights reserved.
1212
=============
1313
*/
@@ -528,7 +528,7 @@ class OnAudioQuery {
528528
return renamePlaylist(playlistId, newName);
529529
}
530530

531-
//Permissions methods
531+
// Permissions methods
532532

533533
/// Used to check Android permissions status
534534
///
@@ -566,7 +566,7 @@ class OnAudioQuery {
566566
return platform.permissionsRequest();
567567
}
568568

569-
//Device Information
569+
// Device Information
570570

571571
/// Used to return Device Info
572572
///
@@ -587,4 +587,45 @@ class OnAudioQuery {
587587
Future<DeviceModel> queryDeviceInfo() async {
588588
return platform.queryDeviceInfo();
589589
}
590+
591+
// Others
592+
593+
/// Used to scan the given [path]
594+
///
595+
/// Will return:
596+
///
597+
/// * A boolean indicating if the path was scanned or not.
598+
///
599+
/// Usage:
600+
///
601+
/// * When using the [Android] platform. After deleting a media using the [dart:io],
602+
/// call this method to update the media. If the media was successfully and the path
603+
/// not scanned. Will keep showing on [querySongs].
604+
///
605+
/// Example:
606+
///
607+
/// ```dart
608+
/// OnAudioQuery _audioQuery = OnAudioQuery();
609+
/// File file = File('path');
610+
///
611+
/// try {
612+
/// if (file.existsSync()) {
613+
/// file.deleteSync();
614+
/// _audioQuery.scanMedia(file.path); // Scan the media 'path'
615+
/// }
616+
/// } catch (e) {
617+
/// debugPrint('$e');
618+
/// }
619+
/// ```
620+
///
621+
/// Platforms:
622+
///
623+
/// | Android | IOS | Web |
624+
/// |--------------|-----------------|-----------------|
625+
/// | `✔️` | `❌` | `❌` | <br>
626+
///
627+
/// See more about [platforms support](https://github.com/LucJosin/on_audio_query/blob/main/on_audio_query/PLATFORMS.md)
628+
Future<bool> scanMedia(String path) async {
629+
return await platform.scanMedia(path);
630+
}
590631
}

on_audio_query/lib/on_audio_query.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
=============
33
Author: Lucas Josino
44
Github: https://github.com/LucJosin
5-
Website: https://lucasjosino.com/
5+
Website: https://www.lucasjosino.com/
66
=============
77
Plugin/Id: on_audio_query#0
88
Homepage: https://github.com/LucJosin/on_audio_query
99
Pub: https://pub.dev/packages/on_audio_query
10-
License: https://github.com/LucJosin/on_audio_query/blob/main/LICENSE
10+
License: https://github.com/LucJosin/on_audio_query/blob/main/on_audio_query/LICENSE
1111
Copyright: © 2021, Lucas Josino. All rights reserved.
1212
=============
1313
*/

on_audio_query/lib/widget/query_artwork_widget.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
=============
33
Author: Lucas Josino
44
Github: https://github.com/LucJosin
5-
Website: https://lucasjosino.com/
5+
Website: https://www.lucasjosino.com/
66
=============
77
Plugin/Id: on_audio_query#0
88
Homepage: https://github.com/LucJosin/on_audio_query
99
Pub: https://pub.dev/packages/on_audio_query
10-
License: https://github.com/LucJosin/on_audio_query/blob/main/LICENSE
10+
License: https://github.com/LucJosin/on_audio_query/blob/main/on_audio_query/LICENSE
1111
Copyright: © 2021, Lucas Josino. All rights reserved.
1212
=============
1313
*/

0 commit comments

Comments
 (0)