1

私はすべての活動のために自分のアプリで曲を作ろうとしています。最初のアクティビティで MediaPlayer をセットアップすると、すべてのアクティビティが再生されますが、ゲームのアクティビティでは停止します。ゲーム アクティビティでメディアをもう 1 つ作成しようとしましたが、再生されません

最初のアクティビティ:

public class MainStage extends Activity implements OnClickListener {


 private Button newGameBtn,highScoreBtn;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.main_game);
    final MediaPlayer themeSong =MediaPlayer.create(this, R.raw.main_song);
    themeSong.start();
    newGameBtn=(Button)findViewById(R.id.new_game);
    newGameBtn.setOnClickListener(this);

    highScoreBtn=(Button)findViewById(R.id.high_score_btn);

    highScoreBtn.setOnClickListener(this);



}

ゲームのアクティビティ:

 @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    club=new Club();
    clubView = new ClubView(this, club);
    mole=new Mole();
    stageView=new StageView(this);
    moleView=new MoleView(this,mole);
    pointsView=new PointsView(this);

    time=new Time(this);
    timerView=new TimerView(this, time);

    allViews=new AllViews(this);
    allViews.setViews(stageView, moleView, pointsView, timerView,clubView);
    setContentView(allViews);
    MediaPlayer themeSong =MediaPlayer.create(this, R.raw.main_song);
    themeSong.start();

    allViews.setOnTouchListener((View.OnTouchListener)this);
4

0 に答える 0