J2ME播放声音CODE

try {
               InputStream is = getClass().getResourceAsStream("/ringin.wav"); //以输入流的形式获取声音资源
               Player p =javax.microedition.media.Manager.createPlayer(is, "audio/x-wav"); //创建Player 对象
              
               p.prefetch(); //声音的预读去
               p.start(); //播放声音
               } catch (IOException ex)
               {
               //捕获IO 异常
               }
               catch (MediaException ex)
               {
               //捕获声音文件异常
               }

posted @ 2008-12-18 14:08  飘逸的程序员  阅读(507)  评论(0编辑  收藏  举报