WTK为何无法播放音乐?
package test;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import java.io.*;
public class Sound extends MIDlet
{
private Player player = null;
/** Constructor */
public Sound()
{
try
{
InputStream is = this.getClass().getResourceAsStream("G:/workspace/J2ME/Study/test/Blip.wav");
player = Manager.createPlayer(is, "audio/x-wav");
}
catch (
IOException e)
{
System.out.println("1:" + e);
}
catch (MediaException e)
{
System.out.println("2:" + e);
}
catch (Exception e)
{
System.out.println("3:" + e);
}
}
/** Main method */
public void startApp()
{
if (player != null)
{
try
{
player.start();
}
catch (MediaException e)
{
System.out.println("4:" + e);
}
}
}
/** Handle pausing the MIDlet */
public void pauseApp()
{
}
/** Handle destroying the MIDlet */
public void destroyApp(boolean unconditional)
{
}
}
以上代码为何用没有音乐播放?毕业设计做ME的音乐播放器,从网络上找了最基本的播放代码,发现却无法播放而且出现一下异常:
3:
java.lang.IllegalArgumentException
Execution completed.
3445081 bytecodes executed
1237 thread switches
1667 classes in the system (including system classes)
17851 dynamic objects allocated (536712 bytes)
2 garbage collections (461416 bytes collected)
示例的网站上是用NOKIA的S60的模拟器,我也下了安装了实验但是依旧没有声音放出来。而且出现一下异常
WARNING: Attribute value for MicroEdition-Configuration defined in JAR manifest is not supported.
Emulator command: C:\WTK2.5.2_01\wtklib\devices\Series_60_MIDP_SDK_2_1_Chinese\bin\Epoc32\release\winscw\udeb\kmidp20.exe test.Sound -classpath c:\tmp\midp\Study.jar -descriptor c:\tmp\midp\Study.jad Sound
java.io.IOException
at com.symbian.midp.runtime.NativeFile.open(+11)
at com.symbian.midp.runtime.Jar.open(+5)
at com.symbian.midp.runtime.MIDletSuiteAMS.initialize(+129)
at com.symbian.midp.runtime.MIDletSuiteAMS.run(+5)
at com.symbian.midp.runtime.MIDletSuiteAMS.main(+16)
本人用的是Eclipse3.2.2和WTK2.5.2的版本。求高手解答。。。能否毕业就看这个了!膜拜下先!OTZ
------解决方案--------------------自己顶上来。。。
InputStream is = this.getClass().getResourceAsStream("G:/workspace/J2ME/Study/test/Blip.wav");
这个没法获取流啊。。。哪个高手教教blip.wav文件应该放哪里啊
------解决方案--------------------你的路径应该不对
如果是放在res下就直接"/Blip.wav"
再么"file:///....."
另外,WAV格式的有些文件因为波特率的不同而不被支持,注意一下.
------解决方案--------------------如果我想播放mp3格式的音乐,该怎么办呢?