Issue while reading MP3 from Assests through AssetFileDescriptor
<p>I am writing a piece of code that plays mp3 file from the assets folder of the project.
Below is the code which I am using. The problem I am facing is even when valid_invalid is true, it is playing fail_sound.mp3 instead of successsound.mp3.</p>

<pre><code>mMediaPlayer = new MediaPlayer(); // idle state
mMediaPlayer.reset();
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
AssetFileDescriptor assest;

try {
    if(valid_invalid==true)
        assest = getAssets().openFd("successsound.mp3");
    else
        assest = getAssets().openFd("fail_sound.mp3");
    TicketProBase.logMessage("Song Service Valid_invalid="+valid_invalid);
    if(assest==null){
        TicketProBase.logMessage("Song Service: AssetFileDescriptor is null");
        stopSelf();
    }
FileDescriptor descriptor=assest.getFileDescriptor();
if(descriptor==null){
    TicketProBase.logMessage("Song Service: FileDescriptor is null");
    stopSelf();
}
    mMediaPlayer.setDataSource(descriptor/*, assest.getStartOffset(), assest.getLength()*/);
    descriptor=null;
    assest.close();
    assest=null;
    mMediaPlayer.prepare();
    mMediaPlayer.setOnPreparedListener(this);
    mMediaPlayer.setOnCompletionListener(this);       
</code></pre>

<p>In OnPreparedListener:<br/><br>
                public void onPrepared(MediaPlayer mp) {
        mp.seekTo(0);
        mp.start();
    }<br>
According to me, the problem is related to caching of music file with the FileDescriptor. At the starting, there was no if else block. I wrote one line code,<br>
        assest = getAssets().openFd("fail_sound.mp3");    <br>
<br>So, May be this music file is cached in the memory and so whenever this code runs, it plays fail_sound.mp3.<br>
Please provide inputs if anybody has gone through this issue.</p>
