0

在我的 android 应用程序中,我想在加载启动程序时播放 mp3 音调。我已经完成了动画启动程序。这是我的代码。请有人帮我播放 mp3 音调。

package com.bni.www;

 import android.app.Activity;
 import android.content.Intent;
 import android.graphics.PixelFormat;
 import android.os.Bundle;
 import android.os.CountDownTimer;
 import android.view.Window;
 import android.view.WindowManager;
 import android.view.animation.Animation;
 import android.view.animation.AnimationUtils;
 import android.widget.ImageView;
 import android.widget.LinearLayout;


public class Main extends Activity {



 public void onAttachedToWindow() {
     super.onAttachedToWindow();
     Window window = getWindow();
     window.setFormat(PixelFormat.RGBA_8888);
    }


   @Override
   public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

 setContentView(R.layout.spalsh);
 CountDown _tik;
 _tik=new CountDown(12000,100,this,Login.class);
 //Intent intent=new Intent(Main.this,Login.class);   
 _tik.start();
 StartAnimations();
 //startActivity(intent);
}
  private void StartAnimations() {
 Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
 anim.reset();
 LinearLayout l=(LinearLayout) findViewById(R.id.lin_lay);
 l.clearAnimation();
 l.startAnimation(anim);

 anim = AnimationUtils.loadAnimation(this, R.anim.translate);
 anim.reset();
 ImageView iv = (ImageView) findViewById(R.id.logo);
 iv.clearAnimation();
 iv.startAnimation(anim);

   }



 }


 class CountDown extends CountDownTimer{
 private Activity _act;
 private Class _cls;
 public CountDown(long millisInFuture, long countDownInterval,Activity act,Class cls) {
 super(millisInFuture, countDownInterval);
 _act=act;
 _cls=cls;
 }
 @Override
 public void onFinish() {
 _act.startActivity(new Intent(_act,_cls));
 _act.finish();
 }
@Override
public void onTick(long millisUntilFinished) {

 }
}
4

1 回答 1

0

使用此代码播放音频。

mp = MediaPlayer.create(yourclassname.this, R.raw.mysound);
                        mp.setOnCompletionListener(new OnCompletionListener() {

                            @Override
                            public void onCompletion(MediaPlayer mp) {
                                // TODO Auto-generated method stub
                                mp.release();
                            }

                        });   
                        mp.start();
于 2012-10-05T19:00:29.043 回答