나는 android에서 새롭고 다른 (간단한?) 문제가 있습니다. Media Player를 중지하는 방법을 모르겠습니다. 이것은 내 간단한 코드입니다 :미디어 플레이어 중지
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view);
MediaPlayer mp;
mp = MediaPlayer.create(this, R.raw.sauronsound);
mp.setLooping(false);
mp.start();
@Override
protected void onDestroy()
{
// Stop play
super.onDestroy();
mp.stop();
}
}
첫 번째 활동으로 이동하지만 사운드는 켜져 있습니다. 앱을 떠날 때도 켜져 있습니다. 소리를 끄려면 어떻게해야합니까?
언제나 가난한 영어로 변명하십시오.
나는 너희들 덕분에 문제를 해결했다. 작업 코드 :
public class SauronEye extends Activity {
private MediaPlayer mp;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view);
mp = MediaPlayer.create(this, R.raw.sound);
mp.setLooping(false);
mp.start();
// Get instance of Vibrator from current Context
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(10000);
}
@Override
protected void onStop()
{
// Stop play
super.onStop();
mp.stop();
}
}
올바른지? 작동합니까? 도와 주셔서 감사합니다. 이 밖에 http://developer.android.com/reference/android/media/MediaPlayer.html 당신은 mp.stop()를 호출 할 수있는 방법, 중지 또는 당신이 당신의 onpause가 호출 될 것이다 버튼을 다시 선택하여 requirement.When에 따라 일시 정지
감사합니다이 비디오 시리즈를 시도 할 수 있습니다 soundcodes으로 :) 당신은 – jundymek