vanilla-music / vanilla

Vanilla Music Player for Android
GNU General Public License v3.0
1.18k stars 295 forks source link

Add a shortcut for 'scan full filesystem' #822

Closed andiandi13 closed 5 years ago

andiandi13 commented 6 years ago

There's something that embarrass me with Vanilla that I don't have to think of while testing other players.

It's updating the media library when I do some quick changes on my SDCard (moving a song, renaming a song...).

Vanilla keep it's old library and tell me the song can't be played.

I don't know if its because my android media library don't update but in other player it's quickly updated.

With Vanilla I always have to rescan my entire SDCard (its fast so no problem).

I think you should put a shortcut of 'scan full filesystem' in the 3-dot menu with Now Playing/Setting/Show queue/Sort By, called 'Rescan device' for example.

I think you added a function of periodic scan but for newer android versions, correct me if I'm wrong.

Kaned1as commented 6 years ago

@adrian-bl I have an idea.

  1. Music directories have a lot less folders than they have files.
  2. Directory modification time changes if and only if file/dir inside it is deleted or created.

So what if we keep track of all folders inside the music dir and periodically check their modtime? Something like FileAlterationMonitor from Apache Commons? Then we could rescan only affected one much more efficiently.

adrian-bl commented 6 years ago

@andiandi13 I'd rather fix the root cause than adding a shortcut to the scan option:

Do you really need to tick the 'scan full filesystem' option? That would indicate that the missing files aren't even indexed by android.

Also note that we run regular background scans, but this only happens on newer firmware (6 if i recall correctly?) due to the missing API support on older devices.

@Adonai We already check the mtime of indexed files: if a files mtime is <= what we saw last, we won't even bother to read it. What slows down the scan is the reading of unindexed files. Optimizing this would indeed be nice - but maybe just using a bloom filter would be sufficient? That would be faster than having to index EVERY file and also frees us from the 'cleanup' work (you can just throw the filter away once in a while or flip bits back)

andiandi13 commented 6 years ago

@adrian-bl Better to fix the cause yes. So, if I don't scan the full filesystem, the old songs that won't play anymore would be removed from Vanilla's database, but new songs won't appear.

I have to scan full filesystem to load new tracks (even if I move a file or rename it)

andiandi13 commented 6 years ago

@adrian-bl : I just see that some players have a cool option to do a quick scan of the library at the start of the app to update changes.

The only thing we'd do after some update of the library (rename, move, copy songs...) is to exiting the app with the back key and relaunch it.

It would be a nice compromise wouldn't it ?

M1Aston commented 6 years ago

Agreed with everything above. Having removed files in the list (can't be played, obviously) is awkward.

andiandi13 commented 6 years ago

I though about swipe down to update, but I don't asked since I think it's a lollipop feature, so Kit Kat users won't have it.

The minimum IMO would be to do a quick scan (not full filesystem) at start.

Edit : and I wanted to add that vanilla should work efficiently on its own without users asking "why is that?" "Where are my songs?" "How to do that". Regarding library there is too much "manual" things to do especially updating it.

M1Aston commented 6 years ago

The ''swipe down to scan'' works perfectly well with the latest android version. AIMP doesn't do automatic file scans\updates either (like Vanilla), but it does have a swipe down feature. It works perfectly well. I wish Vanilla would get it as well, because the way it works now is a pain in the neck.

By the way, are the developers active in this forum?

adrian-bl commented 6 years ago

I submitted https://github.com/vanilla-music/vanilla/commit/13fff22d0cce2e4f9a822be3fccce01de0cbb418

This change makes background scans (which get scheduled on >= 5.x devices) and manually triggered scans more aggressive by inspecting the full native media library (instead of just checking whatever we assume to be new).

Hopefully, this will reduce the requirement to manually trigger scans.

M1Aston commented 6 years ago

That sounds good. I can't wait to give it a try. Thanks very much.