Java Applet播放声音文件与Windows Media Player有不同的效果吗?
我有一个自动拨打电话号码的Java程序,它可以生成模仿电话键盘的声音,正常通话效果很好,但是我在电话卡方面遇到了问题,它要求我输入卡号,生成的声音我的程序没有被另一端接受,它总是说卡号不正确,所以我做了一些研究,找到了一个可以为我生成整个卡号声音序列的网站,我保存了它,但问题是当我使用下面的Java方法播放*.wav声音文件时,它仍然不被接受,但如果我用Windows Media Player播放相同的文件,另一端会接受它作为有效的卡号声音,为什么?这是否意味着Java Applet播放声音文件的效果与Windows Media Player不同?
void playAudioFile(String File_Name)
{
try { Applet.newAudioClip(new URL("file:/"+File_Name)).play(); }
catch (Exception e) { e.printStackTrace(); }
}
如果是这样,我如何在我的Java程序中调用Windows Media Player来播放声音?
I have a Java program that auto dials phone numbers, it can generate sounds to mimic phone keypads, works fine for normal calls, but I encountered a problem when it comes to calling card, it requires me to enter a card number, the sounds generated by my program were not accepted by the other end, it always said the card number is incorrect, so I did some research and found a site that would generate the entire card number sound sequence for me, and I saved it, but the thing is when I used the following Java method to play the *.wav sound file, it's still not accepted, and yet if I play the same file back with Windows Media Player, the other end would accept it as a valid card number sound, why ? Does that mean Java Applet play sound file has a different effect than Windows Media Player ?
void playAudioFile(String File_Name)
{
try { Applet.newAudioClip(new URL("file:/"+File_Name)).play(); }
catch (Exception e) { e.printStackTrace(); }
}
If so, how can I, in my Java program, call Windows Media Player to play the sound ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我调整了音量,现在效果很好。
I tuned up the sound volume, now it works fine.
我无法告诉您为什么会看到这种效果,但我可以告诉您如何从您的程序启动 Windows Media Player。
假设使用 Windows XP 和 Windows Media Player 11:
这将启动 Windows Media Player 并使其播放 File_Name 指向的文件(完整路径可能是最安全的)。如果媒体播放器已经打开,那么它仍然可以工作:)任何当前播放的文件都将被中断。
我希望这有帮助。
I can't tell you why exactly you are seeing this effect, but I can tell you how to launch Windows Media Player from your program.
Assuming Windows XP and Windows Media Player 11:
This will launch Windows Media Player and make it play the file that File_Name points to (full path would probably be safest). If Media Player is already open then it will still work :) Any currently playing file will be interrupted.
I hope this helps.