Java Reference
In-Depth Information
int sw = 6;
int sx = x + (w - sw) / 2;
int sy = y + h - 8;
g.setColor(0xffffff);
g.fillRect(sx, sy, sw, sw);
g.setColor(0x000000);
g.drawRect(sx, sy, sw, sw);
g.drawLine(sx, sy, sx + sw, sy + sw);
g.drawLine(sx, sy + sw, sx + sw, sy);
}
private boolean isBlack(int note) {
return kBlack[note];
}
public void keyPressed(int keyCode) {
int action = getGameAction(keyCode);
switch (action) {
case LEFT:
mCurrentNote--;
if (mCurrentNote < 60)
mCurrentNote = 60;
repaint();
break;
case RIGHT:
mCurrentNote++;
if (mCurrentNote > 72)
mCurrentNote = 72;
repaint();
break;
case FIRE:
try { Manager.playTone(mCurrentNote, 1000, 100); }
catch (MediaException me) {}
break;
default:
break;
}
}
}
The ABB also offers support for playing sampled audio files, although the specification
does not require support for this feature. To play sampled audio, you just need to get a Player
for the data you wish to hear, and then start the Player running. You can get a Player by asking
Manager for one. In its simplest form, playing sampled audio data looks like this:
URL url = "http://65.215.221.148:8080/wj2/res/relax.wav";
Player p = Manager.createPlayer(url);
p.start();
Search WWH ::




Custom Search