Im coding a music-streaming-server. So i created 2 docker containers,Client and Server. Now im trying to stream .wav file from server to client.
The following piece of code is where im trying to play the received audio data from server using AudioInputStream
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);
}
First i tested my code on NetBeans IDE and works great. My problem is when im runing it on docker i get javax.sound.sampled.LineUnavailableException
. Documentation says that is an exception indicating that a line cannot be opened because it is unavailable. This situation arises most commonly when a requested line is already in use by another application.
Im confused because i have not opened this file on another application. What might be wrong?