Manager create player

0 respostas
renanbarros

Pessoal , estou com o seguinte problema.

Estou executando um video num player jmf. so que quando eu passo a URL do video via parametro no applet , ele nao reconhece a url.

mas quando seu coloco a mesma url dentro de uma String passando diretamente dentro do codigo eu consigo exibir.

o erro no applet:

Could not find error.connectionerror
java.io.IOException: Unable to open a URL connection
Could not find error.connectionerror
java.io.IOException: Unable to open a URL connection
Got exception Error instantiating class: com.sun.media.protocol.http.DataSource : java.io.IOException: Unable to open a URL connection
java.lang.NullPointerException
	at PlayerApplet.start(PlayerApplet.java:37)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

e este e o codigo do meu .java q pega a url do applet .

public class PlayerApplet extends Applet  implements ControllerListener {
   Player player = null;


   
   public void init() {
      setLayout(new BorderLayout());
      String mediaFile = null;
      URL url = null;
        try {
          ///  mediaFile= getParameter("FILE");
     // mediaFile ="http://www.renanalmeidadebarros.kit.net/som/testefilme.mpg";
     mediaFile ="http://10.3.186.204:8001/NT0000AF66.mpg";
            
            
            url = new URL(getDocumentBase(),mediaFile);
        } catch (MalformedURLException ex) {
            ex.printStackTrace();
        }
      try {
         MediaLocator ml;
         ml = new MediaLocator(url);
         player = Manager.createPlayer(ml);
         player.addControllerListener(this);
      } 
      catch (Exception e) {
         System.err.println("Got exception "+e);
      }
   }
   
   public void start() {
      player.start();
   }
   public void stop() {
      player.stop();
      player.deallocate();
   }
   public void destroy() {
      player.close();
   }
   public synchronized void controllerUpdate(ControllerEvent event) {
      if (event instanceof RealizeCompleteEvent) {
         Component comp;
         if ((comp = player.getVisualComponent()) != null)
            add ("Center", comp); 
         if ((comp = player.getControlPanelComponent()) != null)
            add ("South", comp);	    
         validate();
      }
   }
}
Criado 15 de janeiro de 2007
Respostas 0
Participantes 1