微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

音频剪辑:javax.sound.sampled.LineUnavailableException

如何解决音频剪辑:javax.sound.sampled.LineUnavailableException

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

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

int length = fromServer.readInt();//takes audio file length from socket
if (length > 0) {
  byte[] message = new byte[length];
  fromServer.readFully(message,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)

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。