我正在尝试从我的 android 设备读取音乐文件的内容,尽管我已经能够检索文件并播放它们,但我需要读取音乐文件并将它们转换为字节数组。有人可以帮助我:以下是我的代码:
public void retrieve_music_files() {
music_column_index = musiccursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
musiccursor.moveToPosition(position);
String filename = musiccursor.getString(music_column_index);
Cursor musiccursor;
MediaPlayer mMediaPlayer;
int music_column_index;
try {
if (mMediaPlayer.isPlaying()) {
mMediaPlayer.reset();
}
mMediaPlayer.setDataSource(filename);
mMediaPlayer.prepare();
mMediaPlayer.start();
} catch (Exception e) {
}
}