MP3 won't stream with JMF

后端 未结 3 987
陌清茗
陌清茗 2021-02-06 01:50

Basic idea is to access .mp3 file and send it through RTP stream to other client, who will want to play that song.

Here is RTPServer.java, which I found online and modif

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-06 02:34

    My environment cannot detect the newly added plugin. I would have to hardcode the codec into the track. It works but the mp3 is cluttering. .wav is perfectly fine though.

    javax.media.Codec codec = (javax.media.Codec) (Class.forName(plugins.get(0)).newInstance());
        com.sun.media.codec.audio.mp3.JavaDecoder decoder = new com.sun.media.codec.audio.mp3.JavaDecoder();
        Codec[] cc = new Codec[2];
        cc[0] = codec;
        cc[1] = decoder;
        try {
            tracks[0].setCodecChain(cc);
        } catch (UnsupportedPlugInException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (NotConfiguredError e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    

提交回复
热议问题