2

我正在尝试使用 AudioClip 向我的扬声器播放文件。提到我在 docker 容器上运行它

在这里,我从我的服务器获取音频文件信息并尝试播放它。

int length = fromServer.readInt();//takes audio file length from socket
if (length > 0) {
  byte[] message = new byte[length];
  fromServer.readFully(message, 0, message.length);//reads the data in socket into array "message"

  AudioInputStream oAIS = new AudioInputStream(
  new ByteArrayInputStream(message),
  new AudioFormat(44100.0f, 16, 2, true, false),length); 
  //creates an AudioInputStream which can be used for playing the data
  AudioPlayer.main(oAIS);
 }

当我的程序进入此功能时,我得到

javax.sound.sampled.LineUnavailableException
        at org.classpath.icedtea.pulseaudio.PulseAudioMixer.openImpl(PulseAudioMixer.java:714)
        at org.classpath.icedtea.pulseaudio.PulseAudioMixer.openLocal(PulseAudioMixer.java:588)
        at org.classpath.icedtea.pulseaudio.PulseAudioMixer.openLocal(PulseAudioMixer.java:584)
        at org.classpath.icedtea.pulseaudio.PulseAudioMixer.open(PulseAudioMixer.java:579)
        at org.classpath.icedtea.pulseaudio.PulseAudioDataLine.open(PulseAudioDataLine.java:94)
        at org.classpath.icedtea.pulseaudio.PulseAudioDataLine.open(PulseAudioDataLine.java:283)
        at org.classpath.icedtea.pulseaudio.PulseAudioClip.open(PulseAudioClip.java:402)
        at org.classpath.icedtea.pulseaudio.PulseAudioClip.open(PulseAudioClip.java:453)

可能有什么问题?如果我必须提供任何其他信息,请告诉我

4

0 回答 0