1つの音声ファイルのbitRate、sampleRate、channelCountを取得したい
私はコードを使用します
@SuppressLint("NewApi")
public void GetSampleRate(String path)
{
MediaExtractor mex = new MediaExtractor();
try {
mex.setDataSource(new File(path).getAbsolutePath());// the adresss location of the sound on sdcard.
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
MediaFormat mf = mex.getTrackFormat(0);
bitRate = mf.getInteger(MediaFormat.KEY_BIT_RATE);
sampleRate = mf.getInteger(MediaFormat.KEY_SAMPLE_RATE);
channelCount = mf.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
}
しかし、コンパイラがこの行に来ると
mex.setDataSource(new File(path).getAbsolutePath());
logcat は 1 つのエラーを表示します
10-13 12:57:52.772: E/WVMExtractor(9554): Failed to open libwvm.so: dlopen failed: library "libwvm.so" not found
そして、bitRate、sampleRate、channelCountを取得しようとすると、このエラーが発生します。
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference