TC4A TCMP, Xiaomi, Android 10: problems with tags reading

Support for Android version of Total Commander

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

TC4A TCMP, Xiaomi, Android 10: problems with tags reading

Post by *DrShark »

The problem in TC Media Player which has been on my Xiaomi's Redmi Note 8 Pro device when it had Android 10 in the past is following:

if the .mp3 file which is added to TC Media Player queue is located under
/storage/emulated/0/[...]
path, TC Media Player didn't get from Android Media Database the correct track tags, instead the Media DB returned to TC the word "unknown" (or it was "unknown - file name.mp3" - the name of the file could be added to the title by TC; it's true for files in all subdirs of /storage/emulated/0/[...] except "ringtones", "alarms", and "notifications", which is explained below).

So in the playlist the track titles looked like following:
"unknown - file name.mp3"

while the correct title should be e.g.:
"Track number. - Artist - Title - Date"

Even selecting the files the .mp3 files and using a button with a command 130 Reload (MTP-PC), which calls the update of Android Media Database, didn't help.

There was a workaround for this problem though:
to add to TC Media Player this files using the
/mnt/sdcard/[...]
alias path.

For some reason, for tracks added with such paths TC Media Player showed correct tags!
Very strange thing...

The way TC gets tracks titles is folowing:
1. TC asks Android Media Database (MediaScannerConnection.scanFile: https://developer.android.com/reference/android/media/MediaScannerConnection#scanFile(java.lang.String,%20java.lang.String)
), and if it returns something for a file TC shows that as its tags. Christian Ghisler didn't explain what kind of, if any, possible errors of Android Media Database are handled by TC Media Player or the 130 Reload (MTP-PC) function.
2. For the special directories: ringtones, alarms, and notifications, TC added only custom tags, which TC read directly from MP3, to the Android Media Database manually to the media database (below info is as of October, 2020, see history2.txt for some changes about such special dirs):
title
artist
size
mime type
is_music: false
is_alarm: if in alarm directory
is_ringtone: if in ringtone directory
is_notification: if in notification directory
Then it was added to Media DB with:

Code: Select all

getContentResolver().insert(MediaStore.Audio.Media.getContentUriForPath(fileName), content);
The problem is that for files under /storage/emulated/0/[...] Android didn't return an error after TC asked it with MediaScannerConnection.scanFile, Media database actually returned that "unknown" as a track title, so there is no clear reason for TC to use direct ID3 tags reading instead.

So solution I suggested to Christian Ghisler for TC4A at that time:
when the path to file like /storage/emulated/0/[...]file.mp3 is passed to TC Media Player,
ask Media DB for tags, if it returns info with "unknown" word present - ask again for the same file via /mnt/sdcard/[...]file.mp3 path, and if that returns tags without "unknown" word - use that tags for the track title.

Similar approach could probably work for command 130:
when marked /storage/emulated/0/[...]file.mp3,
command 130 tries to pass that to Media DB,
then checks what's there now for /storage/emulated/0/[...]file.mp3,
and if title with "unknown" is returned,
pass /mnt/sdcard/[...]file.mp3 to Media DB, check what tags Media DB returns for it,
and if there are no unknown words there, remember that data
and then manually try to set tags for Media DB (as you do in /Ringtones/)
for /storage/emulated/0/[...]file.mp3 using data you got for /mnt/sdcard/[...]file.mp3.

Unfortunately, implementing the autosubstitutuion of /mnt/sdcard instead of /storage/emulated/0 in TC Media Player for getting tags, as Christian Ghisler wrote at that time (October, 2020) would take a long time to implement and was postponed to a later version.

Now that my device got an update to Android 11 (with firmware MIUI-V12.5.2.0.RGGEUXM from 2021-07-01, image file name is miui_BEGONIAEEAGlobal_V12.5.2.0.RGGEUXM_40245966cd_11.0.zip), there are changes on this issue:
1. Bad news: on not rooted Android 11 the access to /mnt/sdcard/ is gone, and there is no way for TC4A to get it back (as in case with /0/Android/data/).
2. Good news: TC Media Player now shows the correct tags for *.mp3 files located under /storage/emulated/0/.

So if there are Xiaomi device users, or users of other devices with Android 10 or older, please check whether you have this problem with MP3 tags on your device in TC Media Player, and if the mentioned workaround helps, please share that information.
If Christian will be able to implement that solution with paths autosubstitution for Android 10, testing of that would be much appreciated! (I cannot test on Android 10 obviously now, but also it's obvious not everyone will decide to update to Android 11, so this issue still worth attention).
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
Post Reply