У меня есть cheerapp.wav
или cheerapp.mp3
или какой-то другой формат.
InputStream in = context.getResources().openRawResource(R.raw.cheerapp);
BufferedInputStream bis = new BufferedInputStream(in, 8000);
// Create a DataInputStream to read the audio data from the saved file
DataInputStream dis = new DataInputStream(bis);
byte[] music = null;
music = new byte[??];
int i = 0; // Read the file into the "music" array
while (dis.available() > 0) {
// dis.read(music[i]); // This assignment does not reverse the order
music[i]=dis.readByte();
i++;
}
dis.close();
Для music
байтового массива, который берет данные из DataInputStream
. Я не знаю, какой длины это выделить.
Это необработанный файл из ресурса, а не файл, поэтому я не знаю его размера.