请问JMF老是报找不到设备是怎么回事,我已经安装jmf2.1e

还有我用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

qq_颖_男人_03406653
浏览 1757回答 2
2回答

1994我

没看到你player的类,是不是忘记写了?或者名字写错了?public class SimpleAudioPlayer { private Player audioPlayer = null;

KXFT

看看你的环境变量配置正确了没
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java