我在启动屏幕上为我的应用程序添加了一个 5 秒的声音 mp3,但在加载应用程序时播放会波动,我需要做什么才能流畅播放?
public class Splash extends Activity{
MediaPlayer ourSong;
@Override
protected void onCreate(Bundle TravisLoveBacon) {
// TODO Auto-generated method stub
super.onCreate(TravisLoveBacon);
setContentView(R.layout.splash);
ourSong = MediaPlayer.create(Splash.this, R.raw.onkar);
ourSong.start();
Thread timer = new Thread(){
public void run(){
try{
sleep(4000);
} catch (InterruptedException e){
e.printStackTrace();
}finally{
Intent openStartingPoint = new Intent("com.sport.sport.MAINLAUNCHER2");
startActivity(openStartingPoint);
}
}
};
timer.start();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
ourSong.release();
finish();
}
}