getAssetFileDescriptor from ZipResourceFile merges all mp3 in mediaplayer SOLVED
- by Jordi
I've a program with an Expansion file that stores 4 mp3 in a obb file (zip without compression).
I can retrieve the data, but instead of taking the audio file i asked for, it merges ALL audio files in the same AssetFileDescriptor.
---SOLVED--- with the fixes
Support class
public AssetFileDescriptor getaudio(){
ZipResourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(c,21,21);
AssetFileDescriptor afd=null;
if(take==1) {
afd = expansionFile.getAssetFileDescriptor("file01.mp3");
}else if(take==2 {
afd = expansionFile.getAssetFileDescriptor("file02.mp3");
} //more els eif ............
return afd;
}
In the MediaPlayer class
AssetFileDescriptor fd = Llistat.getInstance().getAudio();
mPlayer.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(),fd.getLength());
mPlayer.prepare();
fd.close();
My problem was that i directly was returning and using a FileDescriptor, while i was needing the AssetFileDescriptor to take its StartOffset and Length.