jmf的简单应用----播放一个mp3

package newpage;

import javax.media.*;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;

public class audioPlayer {
private Player audiop = null;

public audioPlayer(URL url) throws NoPlayerException,
CannotRealizeException, IOException {
audiop = Manager.createRealizedPlayer(url);

}

public audioPlayer(File file) throws NoPlayerException,
CannotRealizeException, MalformedURLException, IOException {
this(file.toURL());
}

public void play() {
audiop.start();
}

public void stop() {
audiop.stop();
audiop.close();
}

public static void main(String[] args) throws NoPlayerException,
CannotRealizeException, MalformedURLException, IOException {

File audioFile = new File("C:\\oracle\\ora92\\ord\\aud\\demo\\aud2.mp3");
audioPlayer player = new audioPlayer(audioFile);

//start the player
player.play();
player.stop();


}
}

你可能感兴趣的:(java,oracle,C++,c,.net)