使用 JLayer 调整音量
我和一个朋友正在将 MP3 播放器编程作为学校项目。我们即将完成,现在陷入了尝试编写一个函数来改变播放器音量的阶段。 我们正在使用:
- AudioDevice
- AdvancedPlayer
我知道其他人已经问了同样的问题,但我没有完全得到解决方案,我不想回答这么老的问题,所以我想我只是再问一次。
干杯 蒂莫西
me and a friend are programming a MP3 Player as a schoolproject. We are nearly finished and now stuck at the point where we try to programm a function to change the volume of the player.
We are using:
- AudioDevice
- AdvancedPlayer
I know someone else asked the same question allready but I did not quite get the solution and I didn't want to respond to such an old question so I thought I'm just gonna ask again.
Cheers
Timothy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的方法是通过 mp3spi 使用 jlayer,这基本上意味着您通过Java声音。然后您可以像在 JavaSound 中一样设置线路增益。
首先,您需要将以下内容添加到类路径中:
...所有这些都在 mp3spi 的发行版中(上面链接)。
其次,您需要在播放之前对 AudioInputStream 进行解码。
然后播放解码后的流:
并且 JavaSound API 控件可用:
注意:不要忘记关闭资源,我刚刚展示了此问题的要点 - 需要熟悉 JavaSound,阅读此处。
The easiest way to do this is to use jlayer via mp3spi which basically means you use jlayer via JavaSound. You can then set gain on the line as you would in JavaSound.
Firstly, you will need to add the following to your classpath:
...all of which are in the distribution for mp3spi (linked above).
Secondly, you will need to decode the AudioInputStream prior to playback.
Then you play the decoded stream:
and JavaSound API controls are available:
NOTE: Don't forget to close your resources, I've just shown the key points for this issue - familiarity with JavaSound is expected, read here.
JLGUI 是基于 UI 的 JLayer 应用程序调整音量的一个很好的示例。您可以在 tar.gz 文件中获取源代码。 http://www.javazoom.net/jlgui/sources.html
JLGUI is a good example of a UI-based JLayer app adjusting volume. You can get the source code in the tar.gz file. http://www.javazoom.net/jlgui/sources.html