“内存不足”诺基亚 5610 加载 MP3 文件时出错

发布于 2024-08-09 14:45:09 字数 634 浏览 6 评论 0原文

我正在开发一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

邮友 2024-08-16 14:45:10

根据我的说法,你的代码是正确的。

我收到“声音不允许”错误,因为手机处于静音模式,而我正在尝试播放它。您确定运行代码时手机未处于静音模式吗?

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?

一念一轮回 2024-08-16 14:45:10

通过直接从 SD mp3 文件和其他此类文件启动以允许手机运行而不会抛出异常(内存不足错误)的诺基亚 Series 40 最准确的来源是:

import java.io.IOException;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import javax.microedition.midlet.MIDlet;
public class pro extends MIDlet {
     public pro() throws IOException, MediaException {

     Player player = Manager.createPlayer("file:///E:/03.mp3");
     player.realize();
     player.start();

     }
  public void startApp() { }
  public void pauseApp() {}
  public void destroyApp(boolean unconditional) {}
}

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:

import java.io.IOException;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import javax.microedition.midlet.MIDlet;
public class pro extends MIDlet {
     public pro() throws IOException, MediaException {

     Player player = Manager.createPlayer("file:///E:/03.mp3");
     player.realize();
     player.start();

     }
  public void startApp() { }
  public void pauseApp() {}
  public void destroyApp(boolean unconditional) {}
}
情痴 2024-08-16 14:45:09

您可能想尝试“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.

别在捏我脸啦 2024-08-16 14:45:09

如果在 player.start(); 之前调用 player.prefetch(); 有什么区别吗?我之前看到的所有例子都是这样完成的。

如果 audio/mpeg 不起作用,也可以尝试使用 mime 类型 audio/mp3

Does it make any difference if you call player.prefetch(); before player.start();? All the examples I have seen previously are done this way.

Also try using the mime type audio/mp3 instead if audio/mpeg doesn't work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文