?? soundeffects.java
字號:
import javax.microedition.media.*;
import java.io.*;
class SoundEffects
{
private static SoundEffects instance;
private Player blastSoundPlayer;
private SoundEffects()
{
blastSoundPlayer = createPlayer("/blast.wav", "audio/x-wav");
}
static SoundEffects getInstance()
{
if (instance == null)
{
instance = new SoundEffects();
}
return instance;
}
void startBlastSound()
{
startPlayer(blastSoundPlayer);
}
void startGameOverSound()
{
startPlayer(createPlayer("/gameover.mid", "audio/midi"));
}
void startHighScoreSound()
{
startPlayer(createPlayer("/highscore.mid", "audio/midi"));
}
private void startPlayer(Player p)
{
if (p != null)
{
try
{
p.stop();
p.setMediaTime(0L);
p.start();
}
catch (MediaException me)
{
// ignore
}
}
}
private Player createPlayer(String filename, String format)
{
Player p = null;
try
{
InputStream is = getClass().getResourceAsStream(filename);
p = Manager.createPlayer(is, format);
p.prefetch();
}
catch (IOException ioe)
{
// ignore
}
catch (MediaException me)
{
// ignore
}
return p;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -