关于J2ME音乐文件播放问题
以下是我写的代码,没有一点声音,也没有错误提示提示,可以输出1和2,请高手帮忙看下
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.media.*;
import java.io.*;
public class wavTest extends MIDlet implements CommandListener
{
private Display display1;
private Form showForm;
private Command wav=new Command("播放",Command.OK,2);
public wavTest()//构造函数
{
display1 = Display.getDisplay(this);
showForm = new Form("音乐播放");
showForm.addCommand(wav);
showForm.setCommandListener(this);
}
public void startApp()throws MIDletStateChangeException
{
display1.setCurrent(showForm);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command cmd,Displayable displayable)
{
if(cmd==wav)
{
System.out.println("1");
try
{
InputStream is = getClass().getResourceAsStream("/abcd.mid");
Player player = Manager.createPlayer(is,"audio/midi");
player.prefetch();
player.setLoopCount(-1);
player.realize();
player.start();
}
catch(
IOException ioe){}
catch(MediaException me){}
}
System.out.println("2");
}
}
------解决方案--------------------你把异常给打出来,具体找到哪一行出错。
------解决方案--------------------该回复于2012-08-13 08:44:11被版主删除
------解决方案--------------------你的乐曲不是放在res下面吗?