Java Applet播放声音文件与Windows Media Player有不同的效果吗?

发布于 2024-08-11 05:00:29 字数 531 浏览 12 评论 0原文

我有一个自动拨打电话号码的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 技术交流群。

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

发布评论

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

评论(2

陪你搞怪i 2024-08-18 05:00:29

我调整了音量,现在效果很好。

I tuned up the sound volume, now it works fine.

鲜血染红嫁衣 2024-08-18 05:00:29

我无法告诉您为什么会看到这种效果,但我可以告诉您如何从您的程序启动 Windows Media Player。

假设使用 Windows XP 和 Windows Media Player 11:

String myCommand = "\"C:\\Program Files\\Windows Media Player\\wmplayer\\\" /open \"" + File_Name + "\""
Runtime.getRuntime().exec(myCommand);

这将启动 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:

String myCommand = "\"C:\\Program Files\\Windows Media Player\\wmplayer\\\" /open \"" + File_Name + "\""
Runtime.getRuntime().exec(myCommand);

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.

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