使用 J2ME 和 Netbeans 6.1 的 6265i Nokia 上的声音问题
目前,我有一些基本代码,可以在按下命令项菜单中的按钮时播放简单的音调。
使用:Manager.playTone(note,uration,volume);
我还有一台黑莓手机,我正在上面测试同一个 midlet,声音效果很好。 那么,这是不允许我播放声音的诺基亚手机特有的情况吗?
我已确保使用正确的 CLDC 和 MIDP 版本来构建它。
我还尝试了 Netbeans IDE 中的音频演示,但仍然没有成功。 它抛出“无法创建玩家”消息。
Currently, I have some basic code to play a simple tone whenever a button is pressed in the command item menu.
Using: Manager.playTone(note, duration, volume);
I also have a blackberry that I'm testing this same midlet on and the sound works fine. So, is this something specific to Nokia phones that aren't allowing me to play the sound?
I've made sure to build it using the correct CLDC and MIDP versions.
I've also tried the audio demos that are in the Netbeans IDE, and still no luck. It throws a "cannot create player" message.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://discussion.forum.nokia.com/forum/showthread。 php?t=91500
诺基亚论坛上的这个帖子似乎表明某些诺基亚型号在使用 Manager.playTone() 函数播放音调时出现问题,更具体地说,会抛出 MediaException,正如您遇到的那样(MediaException 只是如果尝试播放提示音时出现任何问题,则为默认异常)。
您可以在调用 Manager.playTone 后尝试使线程休眠超过提示音的长度。 您可能会进入一种状态,即尝试同时播放两个或多个音调,而手机可能不允许一次创建多个播放器。
如果所有其他方法都失败,您可以使用诺基亚 UI 声音类 (com.nokia.mid.sound.Sound) 来播放铃声。 它已被弃用并被您正在拨打的电话取代,但它可能是您针对该设备的唯一解决方案。 只需创建您自己的 playTone 方法,并让它调用该设备(如果需要的话,也可能是其他诺基亚设备)的诺基亚函数,以及所有其他设备上的 J2ME 标准调用。 您可以使用 Netbeans ME 预处理器来完成此任务。
http://www.theoreticlabs.com/dev/api/nokia-ui-1.1/com/nokia/mid/sound/Sound.html" theoreticlabs.com/dev/api/nokia-ui-1.1/com/nokia/mid/sound/Sound.html
http://discussion.forum.nokia.com/forum/showthread.php?t=91500
This thread on Forum Nokia seems to suggest that certain Nokia models have problems playing tones with the Manager.playTone() function, more specifically a MediaException is thrown, as you are having (MediaException is just the default exception if any problem occurs when trying to play a tone).
You can try sleeping the thread after calling Manager.playTone for greater than the length of the tone. There is a possibility that you get into a state where you are trying to play two or more tones at once and the phone might not allow more than one player to be created at a time.
If all else fails you can use the Nokia UI Sound class (com.nokia.mid.sound.Sound) to play the tone. It is deprecated and replaced with the call you are making, but it might be your only solution for this device. Just make your own playTone method and have it call the Nokia function for this device (and maybe other Nokia devices if need be) and the J2ME standard call on all other devices. You can accomplish this with the Netbeans ME Preprocessor.
http://www.theoreticlabs.com/dev/api/nokia-ui-1.1/com/nokia/mid/sound/Sound.html