import javax.microedition.lcdui.*; import javax.microedition.media.*; public class Second extends Canvas { public int w,h,time; public Player []plr; int music1,music2; public Second() { setFullScreenMode(true); w = getWidth(); h = getHeight(); plr=new Player[4]; time=0; for (int i=0;i<4;i++) { try { plr[i] = Manager.createPlayer(getClass().getResourceAsStream("/m"+i+".mid"), "audio/midi"); plr[i].realize(); plr[i].prefetch(); } catch (Exception ex) { ex.printStackTrace(); } } music1=0; music2=0; } public void paint(Graphics g) { setFullScreenMode(true); time++; if (time<=1) { try { plr[music1].setLoopCount(-1); plr[music1].start(); } catch (Exception ex) { ex.printStackTrace(); } } if (time>=200) { time=0; try { plr[music1].stop(); plr[music1].deallocate(); } catch (Exception ex) { ex.printStackTrace(); } music1++; } if (music1>=4) { music1=0; } g.setColor(0xffffff); g.fillRect(0,0,w,h); g.setColor(0,255,0); g.drawString(" "+music1+" "+time,0,h/2,20); repaint(); } public void keyPressed(int keyCode) { } public void keyRepeated(int keyCode) { } }