0
我正在使用com.googlecode.mp4parser
庫合併音頻文件。我有一個外部音頻mp3文件,我存儲在raw
資源。該文件無法合併由於以下異常,下面是我的代碼:com.googlecode.mp4parser失敗的MP3音頻文件?
閱讀從原始文件夾中的文件:
InputStream is = context.getResources().openRawResource(R.raw.my_mp3_file);
OutputStream output = null;
try {
File file = new File(context.getFilesDir(), "silence.mp3");
if(!file.exists()) {
file.createNewFile();
}
output = new FileOutputStream(file);
byte[] buffer = new byte[4 * 1024]; // or other buffer size
int read;
while ((read = is.read(buffer)) != -1) {
output.write(buffer, 0, read);
}
output.flush();
output.close();
fileReference= file;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace(); // handle exception, define IOException and others
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
代碼讀取電影(這是失敗的):
if(fileReference.exists()) {
Movie m = new MovieCreator().build(fileReference.getAbsolutePath());
}
雖然得到這Movie m
我的代碼失敗拋出異常:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.coremedia.iso.boxes.MovieBox.getBoxes(java.lang.Class)' on a null object reference
它適用於一些MP3文件失敗的原始資源文件?這裏有什麼問題?
找到任何解決辦法? –