import javax.microedition.media.*; import javax.microedition.lcdui.*; import javax.microedition.lcdui.game.*; import java.io.*; /* autor Writer */ public class M extends Canvas { int w,h; Player p,p1,p2; public M() { setFullScreenMode(true); w = getWidth(); h = getHeight(); try { p = Manager.createPlayer (getClass() .getResourceAsStream("/PLR/p.mid"), "audio/midi"); p.realize(); p.prefetch(); p.setLoopCount(1); p1 = Manager.createPlayer (getClass() .getResourceAsStream("/PLR/p1.mid"), "audio/midi"); p1.realize(); p1.prefetch(); p1.setLoopCount(1); p2 = Manager.createPlayer (getClass() .getResourceAsStream("/PLR/p2.mid"), "audio/midi"); p2.realize(); p2.prefetch(); p2.setLoopCount(1); }catch(Exception ex) { ex.printStackTrace(); }} public void paint(Graphics g) { g.setColor(255,255,255); g.fillRect(0,0,w,h); g.setColor(255,0,0); g.drawString("Клавиша 1: p" , 20, 20, 20); g.drawString("Клавиша 2: p1" , 20, 50, 20); g.drawString("Клавиша 3: p2" , 20, 80, 20); } public void keyPressed(int keyCode) { if (keyCode == 49) { try { p.start(); }catch(Exception ex){} } if (keyCode == 50) { try { p1.start(); }catch(Exception ex){} } if (keyCode == 49) { try { p2.start(); }catch(Exception ex){} } } }