Вопрос

hello im trying to create a simple video player with jmf. i think my code its ok but when i execute it i get a NoPlayerException. Here is the code of the player:

package reproductor;
import java.awt.BorderLayout;
import java.awt.Component;
import java.io.IOException;
import java.net.URL;
import javax.media.CannotRealizeException;
import javax.media.Manager;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.swing.JPanel;

/**
 *
 * @author pollyox16
 */
public class repropanel extends JPanel{

    public repropanel(URL url){

    setLayout(new BorderLayout());


    Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);

    try{
    createRealizedPlayer().


    Component video= reproductor.getVisualComponent();
    Component controles=reproductor.getControlPanelComponent();


    if(video!=null){

    add(video,BorderLayout.CENTER);
    }


    if (controles!=null){add(controles,BorderLayout.SOUTH);}

     reproductor.start();//con esto arrancamos el reproductor.
    } //end try


    catch(NoPlayerException e3){
    System.out.println("player not created");

    }
    catch (CannotRealizeException e){
    System.out.println("player not realized");

    }

     catch (IOException e2){
    System.out.println("io exception catch");

    }


    }




}

here is the code of the main application it only creates a JFileChooser and add the url to the player: here is the code of the main application:

package reproductor;
import java.net.URL;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
/**
 *
 * @author pollyox16
 */
public class Reproductor{


    public static void main(String[] args) {


        JFileChooser selectarchivo= new JFileChooser();
        int resultado= selectarchivo.showOpenDialog(null);



        if(resultado== JFileChooser.APPROVE_OPTION){


        URL miurl=null;
        try{



        miurl=selectarchivo.getSelectedFile().toURI().toURL();

        }//FINAL TRY

        catch(Exception e){
            System.out.println("error en el main");       
        }


        if(miurl!=null){
        JFrame ventana= new JFrame("pollyox16");
        ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        ventana.setSize(300,300);
        repropanel mireproductor= new repropanel(miurl);
        ventana.add(mireproductor);
        ventana.setVisible(true);
        }
        }
    }
}

EDIT: here is the exception stacktrace:

javax.media.NoPlayerException: Cannot find a Player for :file:/C:/Users/Public/Videos/Sample%20Videos/Wildlife.wmv
    at javax.media.Manager.createPlayerForContent(Manager.java:1412)
    at javax.media.Manager.createPlayer(Manager.java:417)
    at javax.media.Manager.createPlayer(Manager.java:332)
    at javax.media.Manager.createRealizedPlayer(Manager.java:527)
    at reproductor.repropanel.<init>(repropanel.java:34)
    at reproductor.Reproductor.main(Reproductor.java:52)
Это было полезно?

Решение

javax.media.NoPlayerException: Cannot find a Player for: 
    file:/C:/Users/Public/Videos/Sample%20Videos/Wildlife.wmv

WMV is not listed anywhere in the JMF 2.1.1 - Supported Formats. A 'quick and dirty' test for any media is to load it into the JMF default player. If that player won't load it, neither will any other JMF based app.

I have a page that offers some JMF compatible media that you might choose to test your app. with.


JMF is very old, and has little support for newer formats. If you can convert the video to a format JMF can read, it is fine at playing it, but it is not suited to being a generic 'media player' at this point in time.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top