Why am I getting this LineUnavailableException?

橙三吉。 提交于 2019-12-19 11:55:14

问题


I keep getting the LineUnavailableException on line 34 of my code: https://www.refheap.com/21223

The error reads as javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 44100.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian not supported..

I'm creating multiple instances of the Sound class (implemented in my refheap paste). It seems that the first instances have no problem. But when I start making new instances of Sound objects using the same audio file then I start getting this error.

Any idea how to fix it?

EIDT: I think the ByteArrayInputStream idea from this question might be what I need to do, but I'm not sure how yet.

EDIT: I thought I found a solution in this forum thread on how to play the same sound simultaneously, but after changing my code, I still get the same problem. Here's my updated code, but now the error happens on line 88: https://www.refheap.com/21224


回答1:


I found the solution to the problem: the Beads audio library for Java. Simply amazing.




回答2:


the exception occurs when you try to open multiple data line at a same time. Second line blocks the opening of first data line.



来源:https://stackoverflow.com/questions/20184650/why-am-i-getting-this-lineunavailableexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!