[j2me]利用JLayerMECLDC0.2播放MP3的试验[1]

有一个JLayerME-CLDC0.2,专门是用来在CLDC1.0/MIDP2.0上播放MP3文件以及获取mp3文件的位速/采样率的。

JLayerME是自己做解码器解析MP3格式,然后自行转换为wav格式,这个格式是真机都支持的,然后再让Manager.createPlayer进行播放。

所以非常消耗资源。

他们开发者也说,现在的JLayerME-CLDC0.2还不是一个产品。

这个项目在:

 Project Homepage :
   http://www.javazoom.net/javalayer/javalayerme.html

 JAVA and MP3 online Forums :
   http://www.javazoom.net/services/forums/index.jsp

我在eclipse上可以跑成功,但是传到Nokia真机上就没反应。用Nokia的S60模拟器看,则报告下面的错误,我已经将模拟器的java heap size设置为了16MB:

MMA : Exception during remote invocation
Cannot open the file with the Mp3ToWav datasource!null/class javax.microedition.media.MediaException

不过,对于资源中的mp3,Nokia S60模拟器也能够让JLayerME获取mp3的属性,如下debug信息所示:

-- Mp3Decoder Comments -- Parse Locator : /res/test.mp3
-- Mp3Decoder Comments -- Create decoder and connect the dataSource (Push the wav header)
-- Mp3Decoder Comments -- WAV Stream mode : Frequency: 48000,Channels: 2
Enter createHeader
Generate the WAV header:okay

哪位有兴趣不妨试验看看。

你可以下载我的代码,导入到eclipse:

https://files.cnblogs.com/zhengyun_ustc/JLayerMp3MIdlet.rar

在你的WTK2.2的模拟器上跑时,记得先:

Modify KToolbar preferences to have 16000 KB heap size and VM speed emulation disabled.

原文地址:https://www.cnblogs.com/zhengyun_ustc/p/jlayerme1.html