I have some sounds into a subfolder of assets folder, named audio, and i need to reproduce it. Each sound filename (for now is a .waw files, but later they will become an .mp3) is stored into an array. This is code that i use to reproduce sound:
AssetFileDescriptor descriptor = null;
MediaPlayer player = new MediaPlayer();
try {
descriptor = context.getAssets().openFd("/audio/"+sounds[Integer.valueOf(v.getTag().toString())]);
player.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength());
descriptor.close();
player.prepare();
player.setVolume(1f, 1f);
player.start();
} catch (IOException e) {
e.printStackTrace();
}
but i obtain a FileNotFoundException wher i call openFd method. How can i solve this issue?
Aucun commentaire:
Enregistrer un commentaire