简体   繁体   中英

Sound not stopped if start “on create” void

public class Form1 extends ActionBarActivity { private MediaPlayer mp; Context context; ... setContentView(R.layout.activity_form1);

    if (mp==null) {
        context = this;
        mp = MediaPlayer.create(context, R.drawable.mainmenus);
        mp.setLooping(true);
        mp.start();
    };
.... public void startbook(View view) {

      mp.pause();
      mp.stop();
      mp.reset();
      mp.release();
      mp = null;

    Intent intent = new Intent(Form1.this, Form2.class);
    startActivity(intent);
}

If press button "startbook", sound not stop.

正确代码正确:public static MediaPlayer mp = null

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM