だから私はアンドロイドを通して音を再生しようとしています。IVEはこのようなメディアプレーヤーを作成しました
MediaPlayer player; (outside onCreate())
player = MediaPlayer.create(this, R.raw.theninth); (inside onCreate())
次に、アクティビティ全体でこのプレーヤーを参照します。シェイク時に.start()。.pauseonclickなど。このように見えます
if(mag >= 500) {
if(!started) {
mainView.setText(R.string.waitforit);
player.start();
started = true;
if(doThisOnce) {
timer.schedule(changeText, 26000);
doThisOnce = false;
}
}
player.setVolume((float)(2*mag/3.0),(float)(2*mag/3.0));
}
と
public void stopAudio(View v) {
mainView.setText(R.string.shakeme);
player.pause();
started = false;
}
そのため、問題は、画面をタップしてもプレーヤーが一時停止せず、代わりにアプリの開始テキストに移動することです。アプリ全体をリロードしたのと同じように、アプリをシェイクしてから、同じファイルの別のインスタンスを同じプレイヤーがプレイを開始します。