我有以下代码...
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
它不会崩溃或任何东西,只是不播放声音。有任何想法吗?