1
我試圖在我的活動中使用SoundPool
播放聲音,但我無法聽到聲音。SoundPool不播放聲音
private void beginGame(){
setContentView(R.layout.activity_splash1);
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP){
AudioAttributes aa = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.setUsage(AudioAttributes.USAGE_GAME)
.build();
sp = new SoundPool.Builder()
.setMaxStreams(10)
.setAudioAttributes(aa)
.build();
}else{
sp = new SoundPool(10, AudioManager.STREAM_MUSIC,1);
}
sid = sp.load(Splash1.this,R.raw.bubble,1);
sp.play(sid,1,1,1,0,0.99f);
Thread loading = new Thread() {
public void run() {
try {
sleep(2000);
// TODO NEXT ACTIVITY
}
catch (Exception e) {
e.printStackTrace();
}
finally {
finish();
}
}
};
loading.start();
}
是沒有錯誤執行或它會崩潰的應用程序? –
不存在錯誤 –
您使用哪個API級別進行測試? – 0X0nosugar