Hiding media files from Music Player

by clark » Tue, 28 Apr 2009 07:36:44 GMT

Sponsored Links
 I'm torn between which group to post this too, but since it is for an
application I am working on, I guess I'll stick it here.

So here we go.  I have an application which downloads data onto the
sdcard to be used by the application.  Some of these files are sound
or music files and the music player in android seems to parse these
directories and add these files to the list.  I'd like to somehow
block or hide these files from the music player.  Is there is a way to
do this?

I was thinking it may be possible to name my folder with a period at
the beginning, since linux hides such files.  I'm just not sure if
that is going to hide it from the music player or if there is another
way to handle this.


Hiding media files from Music Player

by Marco Nelissen » Tue, 28 Apr 2009 07:51:52 GMT


You could have just tried it, and you would have found that that does indeed
have the effect you're looking for.
Alternatively, you can put a file called ".nomedia" in a directory to
prevent the media scanner from scanning that directory.


Sponsored Links

Hiding media files from Music Player

by clark » Tue, 28 Apr 2009 10:06:48 GMT


Could have, assuming I was at my development machine at the time.
Either way, thanks for the info.


Hiding media files from Music Player

by clark » Tue, 28 Apr 2009 13:08:59 GMT

 Just tried it and the sounds are showing up in the music player.  So
much for that idea.  Anyone else  have experience with this?

I guess I can try changing the extension since I pass it the Uri, and
hopefully MediaPlayer and SoundPool don't choke.  I just have quite a
few files and would hate to have to check them and rename them from
within the app or have the users re-download the new data.

Suggestions welcomed.



Hiding media files from Music Player

by nEx.Software » Tue, 28 Apr 2009 14:33:13 GMT

 A quick look shows at the source indicates the MediaScanner omits
files that begin like "._" or are like "Folder.jpg",
"AlbumArtSmall.jpg", "AlbumArt_{...}_Large.jpg" or "AlbumArt_{...}
_Small.jpg". But it all seems to be based on filename. Of course
there's a native method in there "processDirectory" that I don't
understand because I don't understand c++. Maybe that's supposed to
weed out certain folders/files? Of course, I don't know if this helps
at all but I'll let you decide if it does. Almost looks like changing
the extension will be the answer as that appears to be very important
in determining whether the MediaScanner picks up the file.
Good luck, will be interested to see the final answer on this one.


Hiding media files from Music Player

by Marco Nelissen » Tue, 28 Apr 2009 23:32:16 GMT


The native method will skip any folders whose name starts with a period.


Hiding media files from Music Player

by Marco Nelissen » Tue, 28 Apr 2009 23:34:11 GMT

 You put the files in a folder whose name starts with a period, and they
still show up in the music app?
Are you sure it's not the old files in the old location that are still
showing? Can you check that there are actually entries in the media database
whose path (the _data column) includes a folder that starts with a period?


Hiding media files from Music Player

by clark » Tue, 28 Apr 2009 23:52:18 GMT


I actually renamed the folder programmatically and verified that it
was indeed renamed.  Files in media player still show up and play.

I can check the DB once I get home and I am at my development machine,
unless there is an easy way to check that information directly within
the phone.  Music player does not provide file details, unfortunately.


Hiding media files from Music Player

by clark » Wed, 29 Apr 2009 10:20:46 GMT


Actually that did help.  I'm a C++ guy so taking a look at
MediaScanner.cpp in thre OpenCORE git provided some insight.

Based on the code the scanner 'should' omit folders that begin with a
period or folders which contain a file named .nomedia.

A little digging revealed sounds on my sdcard that were similar to the
ones I was using in my app.  Between that and users still complaining
about sounds showing up in their music player I assumed the folder
renaming did not work but indeed it did.

Placing a file named .nomedia in the folder works great as well.


Other Threads

1. Using the same package in two different projects (LVL, Android Library Project)

I'm using the LVL project and referencing that from my main Android
app project (in the usual way).

However, in my main Android app project I also have classes defined in
com.android.vending.licensing (so that I can access package-private
classes in LVL).

This used to work fine until about a week ago (maybe because of an
update of ADT/SDK tools???).

It seems that now, the classes in com.android.vending.licensing are no
longer visible to the main Android app project.

Is this intended behaviour or a bug?


2. Less Monitor Resolution - Emulator not coming up.

Hi All,

I have a monitor with resolution 1140x1200 pixels (~96 dpi, 21 inches).
My emulator settings are as follows: 1240x780 pixels, 7" screen with option
(scale to real device) and 120 dpi.
The emulator comes up fine and works well.

My colleague is having a monitor which can maximum support 1200x700 pixels.
I sent my development image to him and he used the same emulator settings
as mine, but the emulator is not coming up.

P.S.: I tried to simulate the same by giving my monitor the resolution of
and tested my emulator and it works just fine.

Please help me.



3. Exception Logging

4. A new Android forum for Greek developers...

5. Need help preventing ImageView from Overlapping TextView

6. call web service every 50 seconds

7. javax.net.ssl.SSLException: Not trusted server certificate