我正在录制声音并保存了mp3 / wav / 3gpp类型的音频文件我记录的每种类型都很好并且也播放了但是我将它们转换为字节数组以将其保存为parsefile解析。上传的文件没有在那里播放。这是将音频文件转换为字节数组代码:
public byte[] getRecordedBytes() {
byte[] bytes = null;
File file = AssetsHelper.getRecordingFile();
try {
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buf = new byte[(int) file.length()];
for (int readNum; (readNum = fis.read(buf)) != -1;) {
bos.write(buf, 0, readNum); // no doubt here is 0
System.out.println("read " + readNum + " bytes,");
}
bytes = bos.toByteArray();
} catch (IOException ex) {
ex.printStackTrace();
}
return bytes;
}
然后上传文件
ParseFile audioFile = new ParseFile("Audio.mp3",bytes);
audioFile.saveInBackground();
然后像这样生成链接,没有什么可玩的 http://files.parsetfss.com/2466ccc4-53ba-4dc5-a9d1-14dd1842486f/tfss-e51d07f6-954d-4c5e-99af-7a3c0dce60e3-Audio.mp3