Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

song name appears in all Songs List even after deleting it #67

Closed
Su-desh opened this issue Jan 20, 2022 · 3 comments
Closed

song name appears in all Songs List even after deleting it #67

Su-desh opened this issue Jan 20, 2022 · 3 comments
Labels
P: Android Only android platform PRI: High Needs to be resolved sooner than other issues (Critical to plugin function) T: Bug Something isn't working

Comments

@Su-desh
Copy link

Su-desh commented Jan 20, 2022

hi @LucJosin i am getting a very weird error with this plugin .

I deleted a song with the following code

onTap: () async {
                File file = File(widget.singleTrack!.data);
                try {
                  file.deleteSync();
                  if (await file.exists()) {
                    print('Song not deleted');
                  } else {
                    audioDataClass.getMp3Data();
                    audioDataClass.update();
                  }
                } catch (e) {
                  print('$e');
                }

                Get.back();
              }

Song is deleted without any issue from the file system .

But the problem is that this plugin still holds a reference to that song , because when we i use querySongs(); or queryAlbums();
it is showing the deleted song details in ListView, similar to other songs . this should not happen because that song is removed from storage .

I thought this might be a issue because i did not update the song list View after deleting that song but I tried Restarting the app , Flutter clean .
But same result is shown , song is there in the querySongs list .

Android 11 (API 30) .

@LucJosin LucJosin added P: Android Only android platform PRI: High Needs to be resolved sooner than other issues (Critical to plugin function) S: Need test Needs to be reproduced and validated. T: Bug Something isn't working labels Jan 20, 2022
@LucJosin LucJosin added S: Fixed and removed S: Need test Needs to be reproduced and validated. labels Feb 1, 2022
@huangcs427
Copy link

huangcs427 commented Mar 22, 2022

hi, I am using the latest version 2.6.0, and it still seems to have this problem. I need to use the following code during the loop to determine that I am using Android(HUAWEI P50 pro).

List tempList = [];
List<SongModel> querySongs = await _audioQuery.querySongs();
for (var i = 0; i < querySongs.length; i++) {
    var val = querySongs[i];
    File musicFile = File(val.data);
    if (!musicFile.existsSync()) continue;
    tempList.add(val);
}

@LucJosin
Copy link
Owner

Hi @huangcs427. If you're trying to delete the media, call the scanMedia after the delete method. At the moment this is the only way to notify the android MediaStore that some music has been removed.

You can see the example here

@huangcs427
Copy link

Hi @huangcs427. If you're trying to delete the media, call the scanMedia after the delete method. At the moment this is the only way to notify the android MediaStore that some music has been removed.

You can see the example here

Thank you, Great. I'm sorry I didn't see this description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P: Android Only android platform PRI: High Needs to be resolved sooner than other issues (Critical to plugin function) T: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants