java - gwt-voices - wav 文件未播放

标签 java javascript gwt audio

我遵循了 gwt-voices 快速入门 https://code.google.com/p/gwt-voices/wiki/GettingStarted创建并运行简单的 gwt-voices 项目。 我的问题是,当我运行我的项目(Firefox)时,声音没有播放,我不知道为什么。 这是我的代码:

public class GWTProject implements EntryPoint {
    public void onModuleLoad() {
        SoundController soundController = new SoundController();
        Sound sound = soundController.createSound(Sound.MIME_TYPE_AUDIO_WAV_PCM,
        "C:/path/to/the/file/bienvenue.wav");

        sound.play();
        System.out.println(sound);
    }
}

我错过了什么?

感谢您的帮助。

最佳答案

您应该将与 war 目录相关的音频文件放入 gwt 应用程序中。 假设您将 wav 文件放入 MyProject/war/audio/bienvenue.wav

您编码,现在就可以

  SoundController soundController = new SoundController();
    Sound sound = soundController.createSound(Sound.MIME_TYPE_AUDIO_WAV_PCM,
    "audio/bienvenue.wav");

    sound.play();
    System.out.println(sound);

关于java - gwt-voices - wav 文件未播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17134474/

相关文章:

javascript - jQuery 是否在不设置普通事件处理程序的情况下处理事件?

gwt - Gwt 中 Html***Builder 和 Dom***Builder 类的区别

gwt - 为什么?gwt.codesvr=127.0.0.1 :9997 is appended to url?

eclipse - Eclipse中的GWT编译按钮

java - 获取 JButton 的默认边框

javascript - 通过cordova部署时,服务器端meteor代码在哪里运行?

javascript - d3.js 小倍数 map ,每个倍数具有不同的填充国家/地区

java - 关于原语的快速问题

java - 扫描仪在使用 next() 或 nextFoo() 后跳过 nextLine()?

java - 包 grails.plugins.springsecurity 在 jUnit 测试中不存在