admin管理员组文章数量:1312953
I followed the steps here to play audio in Java. From the docs:
Your program might need a specific kind of mixer, or you might want to display a list of all the available mixers so that the user can select one. In either case, you need to learn what kinds of mixers are installed. AudioSystem provides the following method:
static Mixer.Info[] getMixerInfo()
However when I call the method I am getting an empty array. I am developing using JDK 21 on WSL. I am developing a "plain" console Java application without any GUI libraries. Things I have checked:
- I am able to play sound using
ffplay
- I have
libjsound.so
under$JAVA_HOME/lib
Does the use of this API require one to develop a rich Java application like JavaFX etc.? I don't see anything like that mentioned in the docs.
I followed the steps here to play audio in Java. From the docs:
Your program might need a specific kind of mixer, or you might want to display a list of all the available mixers so that the user can select one. In either case, you need to learn what kinds of mixers are installed. AudioSystem provides the following method:
static Mixer.Info[] getMixerInfo()
However when I call the method I am getting an empty array. I am developing using JDK 21 on WSL. I am developing a "plain" console Java application without any GUI libraries. Things I have checked:
- I am able to play sound using
ffplay
- I have
libjsound.so
under$JAVA_HOME/lib
Does the use of this API require one to develop a rich Java application like JavaFX etc.? I don't see anything like that mentioned in the docs.
Share Improve this question edited Jan 31 at 17:22 greg-449 111k235 gold badges109 silver badges159 bronze badges asked Jan 31 at 17:18 morpheusmorpheus 20.4k29 gold badges108 silver badges186 bronze badges 4 |1 Answer
Reset to default 0I think you can count on letting Java select the default mixer, unless you have some special need (which you haven't mentioned).
The code examples in the wiki for the Javasound tag have examples and information for how to use a Clip
or SourceDataLine
.
The supporting code package, javax.sound.sampled is part of Core Java, (no additional libraries needed), but this package does require the inclusion of the module java.desktop.
本文标签: javasoundHow to play audio (wav) in Java AudioSystemgetMixerInfo() returns empty arrayStack Overflow
版权声明:本文标题:javasound - How to play audio (wav) in Java? AudioSystem.getMixerInfo() returns empty array - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741903417a2404001.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
main
method (macOS) – greg-449 Commented Jan 31 at 17:32ldd libjsound.so
, it says it depends onlibasound.so.2
. Does your WSL have that? – VGR Commented Jan 31 at 18:05