简体   繁体   中英

How to create a media player in Java without JMF?

How to create a media player in Java without using the JMF? Some blogs say it's an old version. I also tried using JMF - this is my code.

public class MediaPlayer {

    public static void main(String[] args) {
         Player p;
         try {
            p = Manager.createPlayer(new URL("http://192.168.1.113/asmitha/1.mp4"));
            p.start();
        } catch (NoPlayerException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

This is the message I am getting:

LINEAR, Unknown Sample Rate * out * LINEAR, 8000.0 Hz, 16-bit, Stereo, LittleEndian, Signed, class [S

JMF 2.1 is the latest version, and that was released a long time ago. JMF will probably not support all codec formats. That is probably why you are not able to play the file. There are also a lot of codec licensing issues.

There is a JMF performance pack for windows & *nix which will support more codecs than the default installation. Try that. If that doesn't work take a look at ffmpeg or VLC-J .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM