我有以下代码......
public class GL2JNIActivity extends Activity implements View.OnTouchListener {
...
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
mView = new GL2JNIView(getApplication());
mView.setOnTouchListener(this);
Display display = getWindowManager().getDefaultDisplay();
display.getSize(size);
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
lib.setContext(this);
lib.setSoundPool(new SoundPool(10, AudioManager.STREAM_MUSIC, 0));
lib.getSoundPool().setOnLoadCompleteListener(new OnLoadCompleteListener() {
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId,
int status) {
lib.setLoaded(true);
}
});
lib.setSoundID(lib.getSoundPool().load(this, R.raw.a, 1));
lib.setAudioManager((AudioManager) getSystemService(AUDIO_SERVICE));
setContentView(mView);
}
然后我在另一个类中使用JNI回调来调用它......
public class GL2JNILib {
...
public void playA() {
//setSoundID(getSoundPool().load(context, R.raw.a, 1));
float actualVolume = (float) audioManager
.getStreamVolume(AudioManager.STREAM_MUSIC);
float maxVolume = (float) audioManager
.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
float volume = actualVolume / maxVolume;
// Is the sound loaded already?
if (loaded) {
soundPool.play(soundID, volume, volume, 1, 0, 1f);
Log.e("Test", "Played sound");
}
}
}
但是我想在onCreate中注释该行并取消注释lib中的行(所以我可以更改注释)。但是当我这样做时,我看到以下错误......
E / WVMExtractor(40):无法打开libwvm.so
它不会崩溃或任何东西,只是不播放声音。有什么想法吗?
答案 0 :(得分:1)
您是否偶然在三星设备上进行测试?众所周知,他们没有包含一些库或者为了发布而个性化它们< 5.0。