import javax.microedition.lcdui.*; import javax.microedition.media.*; import java.io.*; public class MyCanvas extends Canvas{ private Image imageSampler; //картинка семплера public MyCanvas(){ setFullScreenMode(true); try{ imageSampler=Image.createImage("/1.png"); //создание картинки семплера }catch(Exception e){} } public void paint(Graphics g){ g.drawImage(imageSampler,0,0,20); repaint(); } public void playSample(int numberSample){ try{ InputStream inputStream=getClass().getResourceAsStream("/"+Integer.toString(numberSample)+".amr"); Player player=Manager.createPlayer(inputStream,"audio/amr"); player.realize(); player.prefetch(); player.start(); }catch(Exception e){} } public void keyPressed(int keyCode){ try{ switch(keyCode){ case KEY_NUM1: playSample(1);break; case KEY_NUM2: playSample(2);break; case KEY_NUM3: playSample(3);break; case KEY_NUM4: playSample(4);break; case KEY_NUM5: playSample(5);break; case KEY_NUM6: playSample(6);break; case KEY_NUM7: playSample(7);break; case KEY_NUM8: playSample(8);break; case KEY_NUM9: playSample(9);break; } }catch(Exception e){} } }