Cannot get SourceDataLine from stream info

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Cannot get SourceDataLine from stream info



I developed a service to play MP3 files using MP3 SPI, even though it works well on my local machine, it throws an exception after I published my service on the server. Here's the Exception catched by logger:


No line matching interface SourceDataLine supporting format PCM_SIGNED 16000.0
Hz, 16 bit, mono, 2 bytes/frame, little-endian, and buffers of -2 to -2 bytes
is supported.



Here's the code snippet that cause the error:


String url = "http://MusicURL.mp3"
AudioInputStream stream = null;
AudioInputStream dstream = null;

try
URL urlFile = new URL(url);
stream = AudioSystem.getAudioInputStream(urlFile);
catch (UnsupportedAudioFileException e)
logger.error("...", e);
catch (IOException e)
logger.error("...", e);

if (stream!=null){
try {
AudioFormat baseFormat = stream.getFormat();
AudioFormat decodedFormat = new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED,
baseFormat.getSampleRate(),
16,
baseFormat.getChannels(),
baseFormat.getChannels() * 2,
baseFormat.getSampleRate(),
false);
dstream = AudioSystem.getAudioInputStream(decodedFormat, stream);
SourceDataLine.Info info = new DataLine.Info(SourceDataLine.class, decodedFormat,
((int)dstream.getFrameLength()*decodedFormat.getFrameSize()));
SourceDataLine line = (SourceDataLine)AudioSystem.getLine(info);



I'm pretty sure the MP3 SPI JAR package is included when uploading my project to the server container, it seems that the error occurs on the last line. Who can tell me why it doesn't work... NEED HELPPP!





The OS of my local machine is Windows, while the environment of the server is Linux.
– SwaggyP
Aug 10 at 6:47









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS