Search code examples
androidsearchindexingmp3media

How to index media files in android for fast search


I have music application which can play music from cloud. Users can download their favorite songs to listen without internet-connection. Earlier file-names of downloaded songs exactly matched their ID in cloud. For example a34dsa335dkf.mp3, 34fdnn34n2n1.mp3, ...

This naming method convenient for fast search. But not convenient for people, because file names like a34dsa335dkf.mp3 don't tell them anything. For example if somebody wants to copy his downloaded song to somewhere else, he will not know what to copy.

I'm looking for some indexing mechanism, so i can name files human-readable (for example Madonna-Frozen.mp3 instead of a34dsa335dkf.mp3) and i can quickly find this files on demand. I can't simply match file-name to ID in cloud. Because of possible duplicates.

Can someone give me advice how can i do that?


Solution

  • I'm not well-experienced on this so please take this as a newbie suggestion. I would suggest to use MP3 metadata to put your user's ID in and rename the files to a more descriptive name like the one you mentioned e.g. Madonna-Frozen.mp3

    There are few Java libraries to read and write MP3 metadata which you may give them a try:

    • jd3Lib is an id3/mp3 library written in Java. It provides functionality for reading mpeg information such as the bitrate, sample rate, channelmode, etc. It also allows the reading, writing, and removal of id3v1 and id3v2 tags

    • JavaMusicTag This library reads song information, such as song title, artist, and album, from an MP3 file. It supports ID3v1, ID3v1.1, Lyrics3v1, Lyrics3v2, ID3v2.2, ID3v2.3, and ID3v2.4 tags. MP3 Frame Headers can also be read. There is a FilenameTag, a ID3v2.4 tag that is intelligently derived from the file name. It contains tag synchronization utilities, multiple save options, and easy tag conversion methods.

    • JAudioTagger is the Audio Tagging library used by Jaikoz for tagging data in Audio files. It currently fully supports Mp3, Mp4 (Mp4 audio, M4a and M4p audio) Ogg, Vorbis, Flac and Wma, there is limited support for Wav and Real formats.

    I'm pretty sure you will get a better approach from experts.