访问限制:由于对所需库C:\ Program Files(x86)\ Java \ jre7 \ lib \ ext \ jmf.jar的限制,无法访问Player类型

时间:2016-07-09 05:37:28

标签: java

我在java中尝试LiveAudioStreaming。通过JMF进行现场直播。我收到了以下错误。 访问限制:由于对所需库C:\ Program Files(x86)\ Java \ jre7 \ lib \ ext \ jmf.jar的限制,无法访问Player类型。 请帮忙。 I used code from this link

以下是代码:

package com.simpleaudioplayer.simpleaudioplayer;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import javax.media.*;   // import JMF classes
import javax.swing.JFileChooser;

public class Main {
    private Player audioPlayer = null;

    public SimpleAudioPlayer(URL url) {
        try {
            //MediaLocator ml=new MediaLocator(url);
            audioPlayer = Manager.createPlayer(url);
        } catch (Exception ex) {
            System.out.println(ex);
        }
    }

    public SimpleAudioPlayer(File file) throws MalformedURLException {
        this(file.toURI().toURL());
    }

    public void play() {
        audioPlayer.start(); // start playing
    }

    public void stop() {
        audioPlayer.stop();  //stop playing
        audioPlayer.close();
    }

    public static void main(String[] args) {
        try {
            // TODO code application logic here
            JFileChooser fc = new JFileChooser();
            fc.showOpenDialog(null);
            File file = fc.getSelectedFile();
            SimpleAduioPlayer sap = new SimpleAduioPlayer(file);
            sap.play();
            //sap.stop();
        } catch (MalformedURLException ex) {
            System.out.println(ex);
        }
    }
}

0 个答案:

没有答案