Recently, while developing an Android application, I decided to integrate sound. While I did use sound effects in another application, I am yet to finish that one. Hence, this was the place where I noticed the problem.
Android has a MediaPlayer class that helps us play media sounds. In the application, I have multiple sounds in the ‘assets’ directory. When I played one sound from the ‘assets’ directory, I noted that ALL sounds play one after the other. Very strange behaviour.
After going through various Q&A on the Internet (primarily StackOverflow), I found the answer. It seems that Android lumps all assets into a single package. Very strange way to arrange files. In case of the media player, even though all you need to give is the file descriptor, it plays all assets. If you wants to play only the file you are interested in, you also need to provide the starting place and the length.
This makes the provision of a file descriptor kind of redundant. If the API expects multiple parameters for proper behavior, it should say so, rather than allowing people to omit parameters and then behaving in a way that is very different from expectations.