还有我用jmf来实现简单的mp3播放也会出现找不到主类的情况代码如下package com.gml.jmf;import javax.media.*;import java.io.File;import java.io.IOException;import java.net.URL;public class SimpleAudioPlayer { private Player audioPlayer = null; public SimpleAudioPlayer(URL url) throws IOException, NoPlayerException, CannotRealizeException { audioPlayer = Manager.createRealizedPlayer(url); } public SimpleAudioPlayer(File file) throws IOException, NoPlayerException, CannotRealizeException { //this(file.toURL()); audioPlayer = Manager.createRealizedPlayer(file.toURL()); } public void play() { audioPlayer.start(); } public void stop() { audioPlayer.stop(); audioPlayer.close(); } public static void main(String[] args) { File audioFile = new File("E:/KuGou/Sam Smith-Writing's On The Wall.mp3"); if(!audioFile.exists()){ try { audioFile.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } try { SimpleAudioPlayer player = new SimpleAudioPlayer(audioFile); player.play(); //player.stop(); } catch (NoPlayerException e) { // TODO Auto-generated catch block System.out.println("没有播放器"); e.printStackTrace(); } catch (CannotRealizeException e) { // TODO Auto-generated catch block System.out.println("不能实现这个"); e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }}运行结果为:错误: 找不到或无法加载主类 com.gml.jmf.SimpleAudioPlayer
添加回答
举报
0/150
提交
取消