2

I'm trying to embed a video with the MPlayer interface in a Javax.Swing JFrame, but I can't get it to work.

This is what I've done:

            Player p = new Player();
            p.setTitle("JMPlayer");
            p.setVisible(true);

            IPlayer player = new IPlayer();
            player.setMPlayerPath("C:\\Java\\MPlayer\\mplayer.exe");
            try {
                try{
                player.open(new File("C:\\Java\\video.mp4"), 
                        "mplayer -wid " + "0x" + Integer.toHexString(Win32.findWindow(null, "JMPlayer")) + 
                        " -vf scale=500:-3 -vo x11 -zoom -ao esd -osdlevel " +
                        "0 -nojoystick -noconsolecontrols -cookies -slave -user-agent NSPlayer " +
                        "-nomouseinput"
                        );
                }catch(Win32.WindowNotFoundException e){

                }
            } catch (IOException ex) {
                Logger.getLogger(Player.class.getName()).log(Level.SEVERE, null, ex);
            }

I also tried doing it with -wid " + Win32.findWindow(null, "JMPlayer") but none of them works. Video keeps opening a different window. How can I embed it to the JFrame? Is the Handle wrong?

Fuczi Fuczi
  • 415
  • 1
  • 5
  • 13
  • Does it need a heavyweight AWT window handle? – Whome Nov 08 '16 at 06:52
  • As an alternative, consider using [`MediaPlayer`](https://docs.oracle.com/javafx/2/api/javafx/scene/media/MediaPlayer.html) (from Java-FX). – Andrew Thompson Nov 08 '16 at 10:32
  • If you know how to embed it to a lightweight componen as a JPanel, how do I get the JPanel HWND @Whome ? – Fuczi Fuczi Nov 09 '16 at 02:45
  • I want MPlayer because it can play almost any kind of video/audio format @AndrewThompson – Fuczi Fuczi Nov 09 '16 at 02:46
  • Is `MediaPlayer` limited in format support? – Andrew Thompson Nov 09 '16 at 05:08
  • @FucziFuczi I don't think Swing JWhatever lightweight components have a real Windows HWND window handle. They only live in a Java swing ui context. Old skool AWTWhatever components have an underlying HWND available. SWT UI components may also provide a real window handle. – Whome Nov 09 '16 at 14:05
  • @AndrewThompson Yes, it's limited [Media Support](http://docs.oracle.com/javafx/2/api/javafx/scene/media/package-summary.html#SupportedMediaTypes) – Fuczi Fuczi Nov 10 '16 at 02:01
  • @Whome MMm I'll try to do it with AWT components :3 – Fuczi Fuczi Nov 10 '16 at 02:02
  • @FucziFuczi Thanks for the link! I'd looked at the `MediaPlayer` docs and not seen any list of supported codecs/file types (& foolishly presumed it was able to support anything supported on the system), but had not thought to examine the package docs. :P – Andrew Thompson Nov 10 '16 at 05:00

0 Answers0