Closed naveensingh closed 11 months ago
if I use the scan media button in the app settings, then go back in the main activity and progress finishes, I get a crash on Android 11 12:33:05.176 E FATAL EXCEPTION: Thread-50 Process: com.simplemobiletools.musicplayer.debug, PID: 11064 java.lang.RuntimeException: setDataSource failed: status = 0x80000000 at android.media.MediaMetadataRetriever.setDataSource(Native Method) at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:244) at com.simplemobiletools.musicplayer.helpers.SimpleMediaScanner.scanFilesManually(SimpleMediaScanner.kt:116) at com.simplemobiletools.musicplayer.helpers.SimpleMediaScanner.access$scanFilesManually(SimpleMediaScanner.kt:20) at com.simplemobiletools.musicplayer.helpers.SimpleMediaScanner$scan$1.invoke(SimpleMediaScanner.kt:41) at com.simplemobiletools.musicplayer.helpers.SimpleMediaScanner$scan$1.invoke(SimpleMediaScanner.kt:39) at com.simplemobiletools.commons.helpers.ConstantsKt.ensureBackgroundThread$lambda-0(Constants.kt:429) at com.simplemobiletools.commons.helpers.ConstantsKt.$r8$lambda$ukHVGNDmwl8QsD9hCK7IQG-Hwww(Unknown Source:0) at com.simplemobiletools.commons.helpers.ConstantsKt$$ExternalSyntheticLambda0.run(Unknown Source:2) at java.lang.Thread.run(Thread.java:923)
added a new string rescan_media
to be translated while this PR gets sorted out, use it please
I'm checking the crash now
java.lang.RuntimeException: setDataSource failed: status = 0x80000000
is this crash a one-time thing or is it happening on every rescan or every time you enable/disable manual scan?
I forgot to add a try/catch block, I'm adding it now...
I could not reproduce that specific crash. The error code 0x80000000
equals -2147483648
meaning UNKNOWN_ERROR
as can be seen in Errors.h here.
https://github.com/SimpleMobileTools/Simple-Music-Player/pull/545/commits/265d87a82be680b4ac397767f1e7550d5a42d9d5 has a workaround and catches all such crashes.
Check again please.
yeah, the crash is fixed now, but I see that progress at the top at every app launch, Im not a fan of that. It takes like 20 seconds for me to finish the scanning
plus the progress bars color isnt updated on resume, only start
I was only keeping it there until I add the scanning notification, removing it now...
Okay, now the progress bar will show up only on the first load, and when manually rescanning using Rescan media
. Is that okay?
cant we show something as soon as possible at first install, maybe the mediastore files? It takes a really long time to show anything now.
now that it's removed, I agree that the Scan files manually
was really unnecessary. Let's hope it won't create any new device or system specific issues.
cant we show something as soon as possible at first install, maybe the mediastore files? It takes a really long time to show anything now.
I was gonna fix that while optimizing the scan time but if you want to release these changes soon, I can make it so that MediaStore is loaded first
It takes a really long time to show anything now.
How many files do you have?
only 168 audio files are present in All tracks tab and All Tracks playlist. But my device is quite packed with photos and other files
Im not in a hurry to release this version, just do it properly
okay then, I'll push all the changes here if this isn't already merged by the time I'm done.
Do you think Loading files... is okay or should I add Scanning... or Scanning files... strings?
Currently using the headset icon for the notification small icon.
I have some readability-related changes but I'll create another PR for it. There are already too many changes here.
if the original string contains "Rescan media", we should definitely show Scanning. Loading doesnt make sense and it is not consistent.
okay, added "Scanning..." string in another PR just in case this one isn't merged soon: https://github.com/SimpleMobileTools/Simple-Music-Player/pull/554
move the string into Commons while it is easy, such strings might easily be used in other apps too
Oka, here it is: https://github.com/SimpleMobileTools/Simple-Commons/pull/1747
Do we also want to move rescan_media
to commons? Not sure which apps can reuse that.
no, that string isnt that generic
ok :)
havent found any issues at initial testing, hope it will work well. Thanks. That was a pretty big rewrite with hopefully a lot of improvements ;)
This PR addresses issues like https://github.com/SimpleMobileTools/Simple-Music-Player/issues/404 and https://github.com/SimpleMobileTools/Simple-Music-Player/issues/394 where users report missing music files in the player.
This PR also closes https://github.com/SimpleMobileTools/Simple-Music-Player/issues/504
Changes and notes:
MediaStore
and database-related code to one classSimpleMediaScanner
MediaStore
MediaStore
, regardless of manual triggers. This is also very useful in cases like https://github.com/SimpleMobileTools/Simple-Music-Player/issues/404 whereMediaStore
may take some time from a few minutes to a few days to scan files added using some unconventional method. When available,MediaStore
info is still preferred over manually scanned info fromMediaMetadataRetriever
.getAlbumImage()
function inMusicService
was expanded to retrieve thumbnails usingMediaMetadataRetriever
,contentResolver.loadThumbnail()
, andThumbnailUtils.createAudioThumbnail()
in that order. The utilization ofThumbnailUtils.createAudioThumbnail()
is advantageous as it employs a slightly enhanced version of the logic we use to find thumbnails from the parent folder.MediaMetadataRetriever
is employed to retrieve album, artist, and other track information for tracks loaded from storage files.Album
andArtist
objects are generated using data acquired fromMediaMetadataRetriever
, along with basic logic to calculate the number of tracks and albums.flags
column was introduced in the tracks table to indicate whether a track was manually scanned. This information is used inMusicService
to determine whether to pass the media store Uri or file path to the media player.album_art_id
columnartists
table was replaced withalbum_art
to reuse computer Uri when loading the thumbnail.hashCode()
is employed to generate an item id, as there is no media store ID available in such cases.I have tested these changes on API levels 23, 25, 27, 29, 30, 32, and 33 and so far everything has been working smoothly, and from what I can tell manual scan is working as well as MediaStore. Not many players can do this.
Things left to do
Comparison method violates its general contract!
crash when sorting by track number (Couldn't reproduce).Rescan media
.