“内存不足”诺基亚 5610 加载 MP3 文件时出错
我正在开发一个j2me应用程序来播放wav和wav。 mp3 文件。
问题是:
- 当尝试在我的手机(诺基亚 5610d)中播放 mp3 文件时,出现“内存不足”错误。
- 当尝试播放 Wav 文件时,它给出“不允许声音”异常。
我的几行代码在这里。
播放 Wav 文件的代码
InputStream is = getClass().getResourceAsStream("/Child.wav");
player = Manager.createPlayer(is, "audio/x-wav");
player.realize(); player.start();
播放 MP3 文件的代码
InputStream is = getClass().getResourceAsStream("/Child.mp3");<br/>
player = Manager.createPlayer(is, "audio/mpeg");
player.realize(); player.start();
请让我知道我的代码有什么问题。
i am developing one j2me application to play wav & mp3 file.
problems are:
- while try to play mp3 file in my phone (nokia 5610d) it is making "Out of memory" error.
- while try to play Wav file it is giving "Sounds are not allowed" exception.
few lines of my code is here.
Code to play Wav file
InputStream is = getClass().getResourceAsStream("/Child.wav");
player = Manager.createPlayer(is, "audio/x-wav");
player.realize(); player.start();
Code to play MP3 file
InputStream is = getClass().getResourceAsStream("/Child.mp3");<br/>
player = Manager.createPlayer(is, "audio/mpeg");
player.realize(); player.start();
Please let me know what is the problem in my code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
根据我的说法,你的代码是正确的。
我收到“声音不允许”错误,因为手机处于静音模式,而我正在尝试播放它。您确定运行代码时手机未处于静音模式吗?
According to me, your code is correct.
I was getting "Sounds not allowed" error because the phone was in silent mode and i was trying to play it. Are u sure tht ur phone is not in silent mode while running your code?
通过直接从 SD mp3 文件和其他此类文件启动以允许手机运行而不会抛出异常(内存不足错误)的诺基亚 Series 40 最准确的来源是:
The most accurate source for Nokia Series 40 without throwing an exception (Out of Memory error) by launching directly from the SD mp3 files and other such files to allow the phone is:
您可能想尝试“audio/wav”而不是“audio/x-wav”。
我还建议使用 FileConnection URL(
Manager.createPlayer("file://localhost/E:/MyFolder/Child.mp3");
例如),因为它通常比使用创建的播放器效果更好Series40 手机上的输入流。You might want to try "audio/wav" instead of "audio/x-wav".
I would also suggest using a FileConnection URL (
Manager.createPlayer("file://localhost/E:/MyFolder/Child.mp3");
for example) as that typically works better than Players created with an InputStream on Series40 phones.如果在
player.start();
之前调用player.prefetch();
有什么区别吗?我之前看到的所有例子都是这样完成的。如果
audio/mpeg
不起作用,也可以尝试使用 mime 类型audio/mp3
。Does it make any difference if you call
player.prefetch();
beforeplayer.start();
? All the examples I have seen previously are done this way.Also try using the mime type
audio/mp3
instead ifaudio/mpeg
doesn't work.