【问题标题】:Play wave file using AudioFormat in java在 java 中使用 AudioFormat 播放波形文件
【发布时间】:2010-06-02 07:10:44
【问题描述】:

在 linux 操作系统上运行我的代码时出现以下异常。此代码在 windows 操作系统上运行良好。以下是异常和使用的代码。

java.lang.IllegalArgumentException: 没有行匹配接口剪辑支持格式 PCM_SIGNED 未知采样率,16 位,立体声,4 字节/帧,支持大端。

AudioFormat format = sourceaudio.getFormat();

format = new AudioFormat(
    AudioFormat.Encoding.PCM_SIGNED,
                format.getSampleRate(),
                format.getSampleSizeInBits() * 2,
                format.getChannels(),
                format.getFrameSize() * 2,
                format.getFrameRate(),
                true);

AudioFileFormat.Type targettype = AudioFileFormat.Type.WAVE;
AudioInputStream targetaudiostream = AudioSystem.getAudioInputStream(format, sourceaudio);

sourceaudio.close();
targetaudiostream.close();
System.out.println("55555555");

URL url = new URL("http://localhost:8084/newvideo/PCMfile.wav");
Clip clip = AudioSystem.getClip();
AudioInputStream ais = AudioSystem.getAudioInputStream(url);
clip.open(ais);

System.out.println("seconds: " + (clip.getMicrosecondLength() / 1000000));

【问题讨论】:

    标签: java audio


    【解决方案1】:

    当在“设备管理器”中禁用音频设备时,我在 Windows 上遇到了同样的错误。我认为问题是 - 音频设备驱动程序,请尝试更新或重新安装它。

    【讨论】:

      猜你喜欢
      • 2015-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多