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)
{
//捕獲聲音文件異常
}