Sun, Audio-player and Sound I/O

后端 未结 1 1675
死守一世寂寞
死守一世寂寞 2020-12-04 03:28

I have a few questions related to Sun, Audio-player and Sound Input/Output

Why is the sun.audio.AudioPlayer package not part of the Java API? Some info

相关标签:
1条回答
  • 2020-12-04 04:01

    sun.audio is undocumented

    Like other sun.* packages, it is undocumented and it might disappear.

    Java Media Framework is old

    It's an optional package, not part of the SE and hasn't been updated in a long time. Oracle has a page on it and it's still available but, well, who knows what will happen to it.

    javax.sound is part of the SE

    This is the current Java sound implementation, it is part of the SE and the tutorial for it can be found here. If you want to use audio in Java this is what you should learn because it's official, it works, it gets updated sometimes and it is well-documented.

    javax.sound does not play mp3

    Why is that? Despite being ubiquitous in file systems, mp3 has a history of licensing and patent issues. Mp3 is a minefield and this may be why Sun/Oracle has not put effort in to supporting it. (If this is why, I don't blame them.)

    If you really want to play mp3 there are some third-party decoders floating around on the web. There is no point in recommending one because all of them will read mp3.


    JavaFX does play mp3

    Use a javafx.scene.media.MediaPlayer. See javafx.scene.media/Supported Media Types. JavaFX is part of the JRE/JDK as of Java 8 (and new versions of Java 7) and will (probably) eventually supersede several SE APIs like javax.sound and javax.swing.

    0 讨论(0)
提交回复
热议问题