播放“*.mp3”的最佳方式是什么? java 中的文件?

发布于 2024-10-09 19:33:14 字数 83 浏览 5 评论 0原文

是否有我可以使用的 VLC 或 MPlayer 接口? 我只是想要一个能够在 Linux 机器上播放歌曲的接口(Servlet -> Java)。

Is there an interface to VLC or MPlayer which I can use?
I simply want an interface (Servlet -> Java) which is able to play songs on a linux machine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

清浅ˋ旧时光 2024-10-16 19:33:15

看来这就是你想要的, JLayer

Seems like this is what you want, JLayer

鹿! 2024-10-16 19:33:15

此任务不需要 JMF。只需将 JMF 的 mp3plugin.jar 添加到应用程序的运行时类路径中即可。然后 Java 声音将能够读取和播放 MP3。

您还可以查看VideoLAN 的 Java 绑定

无论哪种方式,都需要小程序或 JWS 启动的应用程序。

This task does not require JMF. Just add the mp3plugin.jar of the JMF into the run-time class path of the app. and Java sound will then be able to read and play MP3s.

You might also look at Java Bindings for VideoLAN.

Either way, it will require an applet or JWS launched application.

不疑不惑不回忆 2024-10-16 19:33:15

VLC 具有 Java 绑定。以下是文档中的示例:

String[] libvlcArgs = {...add options here...};
MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(libvlcArgs);
FullScreenStrategy fullScreenStrategy = new DefaultFullScreenStrategy(mainFrame);
EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newMediaPlayer(fullScreenStrategy);
String[] standardMediaOptions = {"video-filter=logo", "logo-file=vlcj-logo.png", "logo-opacity=25"}; 
mediaPlayer.setStandardMediaOptions(standardMediaOptions);
mediaPlayer.addMediaPlayerEventListener(new MediaPlayerEventAdapter() {...add implementation here...});
Canvas videoSurface = new Canvas();
mediaPlayer.setVideoSurface(videoSurface);
String mediaPath = "/path/to/some/movie.mpg";
String[] mediaOptions = {};
mediaPlayer.playMedia(mediaPath, mediaOptions);
// Do some interesting things in the application
...
mediaPlayer.release();
mediaPlayerFactory.release();

VLC jas Java bindings. Here's a sample from the docs:

String[] libvlcArgs = {...add options here...};
MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(libvlcArgs);
FullScreenStrategy fullScreenStrategy = new DefaultFullScreenStrategy(mainFrame);
EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newMediaPlayer(fullScreenStrategy);
String[] standardMediaOptions = {"video-filter=logo", "logo-file=vlcj-logo.png", "logo-opacity=25"}; 
mediaPlayer.setStandardMediaOptions(standardMediaOptions);
mediaPlayer.addMediaPlayerEventListener(new MediaPlayerEventAdapter() {...add implementation here...});
Canvas videoSurface = new Canvas();
mediaPlayer.setVideoSurface(videoSurface);
String mediaPath = "/path/to/some/movie.mpg";
String[] mediaOptions = {};
mediaPlayer.playMedia(mediaPath, mediaOptions);
// Do some interesting things in the application
...
mediaPlayer.release();
mediaPlayerFactory.release();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文