Android 单击按钮时发出嘟嘟声
我想在启动游戏时发出声音,我在oncreate中执行了以下代码:Android 单击按钮时发出嘟嘟声,android,Android,我想在启动游戏时发出声音,我在oncreate中执行了以下代码: SoundPool sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); int iTmp = sp.load(getBaseContext(), R.raw.windows_8_notify, 1); // in 2nd param u have to pass your desire ringtone sp.play(iTmp, 1, 1, 0, 0, 1
SoundPool sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
int iTmp = sp.load(getBaseContext(), R.raw.windows_8_notify, 1); // in 2nd param u have to pass your desire ringtone
sp.play(iTmp, 1, 1, 0, 0, 1);
MediaPlayer mPlayer = MediaPlayer.create(getBaseContext(), R.raw.windows_8_notify); // in 2nd param u have to pass your desire ringtone
//mPlayer.prepare();
mPlayer.start();
当我的声音结束时,我如何使它重新开始?我的意思是重放这首歌
Add mPlayer.setLooping(true);
查看要重新开始音乐,请将loop设置为true:
SoundPool sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
// in 2nd param u have to pass your desire ringtone
int iTmp = sp.load(getBaseContext(), R.raw.windows_8_notify, 1);
sp.play(iTmp, 1, 1, 0, 0, 1);
// in 2nd param u have to pass your desire ringtone
MediaPlayer mPlayer = MediaPlayer.create(getBaseContext(), R.raw.windows_8_notify);
// Here set loop to true
mPlayer.setLooping(true);
mPlayer.start();
问候
PS谢谢你的帮助!你知道我在哪里可以找到我的应用程序的音乐吗?我不想放一首真正的歌曲,我想放一首背景音乐,比如在“请勿轻触白色瓷砖”或其他一些游戏中。不同的问题应该放在不同的帖子中。谢谢,这很有效:)你知道我在哪里可以找到我的应用程序的音乐吗?我不想放一首真正的歌,我想放一首背景音乐,比如在《不要轻触白色瓷砖》或其他一些游戏中。。