tags:

views:

1081

answers:

4

I can creat a GUI in javafx and call the JMF component within JavaFx, just like this

public class JMFComponent extends SwingComponent{

    var panel: JPanel;


    public var center: java.awt.Component on replace{
        println("[center] set component: {center}");
        panel.add(center, BorderLayout.CENTER);
    }


    public override function createJComponent():javax.swing.JComponent{
        panel= new JPanel(new BorderLayout());

        var size:Dimension =   new  Dimension(width, height);
        panel.setPreferredSize(size);
        panel.setMinimumSize(size);
        panel.setMaximumSize(size);
        panel.setSize(size);
        return panel;
    }
}

public class MyMedia extends CustomNode {

    var xpos: Number;
    var ypos: Number;
    var dx: Number;

    public var url: java.net.URL;
    public var autoPlay: Boolean;

    public override function create(): Node{

        var comp:java.awt.Component;
        var control:java.awt.Component;
        var w:Number;
        var h:Number;
        var cw:Number;
        var ch:Number;

        var jmfCom:JMFComponent;
        var player = Manager.createRealizedPlayer(url);

        comp=player.getVisualComponent();

        control=player.getControlPanelComponent();

        if (autoPlay) {
            player.start();
        }
        w=comp.getPreferredSize().getWidth();
        h=comp.getPreferredSize().getHeight();
        cw=control.getPreferredSize().getWidth();
        ch=control.getPreferredSize().getHeight();
        jmfCom=JMFComponent {
                    width:w
                    height:h+ch
                    center:  comp
                    blocksMouse: true
                    bottom:  control
                };

        return Group{
            content: [

                jmfCom

            ] 

        }
    }
}

Stage {
    title: "Media Example"
    width: 500
    height: 500
    onClose: function(){ java.lang.System.exit(0);}
    scene: Scene {
        content: MyMedia{
            url: (
                new java.io.File("C://My//Videos//DELTA.MPG")).toURI().toURL()
            autoPlay: true
        }
    }
}

The video can be played within JavaFx gui, but when i move my mouse cursor into the control bar of the JMF player, the video window will move at the same time.

Does anyone have an idea how I can get JMF working normally within JavaFx?

A: 

Why JMF? There is neat API under javafx.scene.media

Honza
A: 

I have a solution. It was, after trying a few changes, set the property "disable" of the component JMFComponent to "false." This can prevent some of the screen that contains the streaming going to move the mouse pointer on it.

jmfCom=JMFComponent {
    width:   w*2
    height:  h*2  //+ch
    center:  comp
    disable: true
};
A: 

Hello, good Afternoon, I do not speak English, but I have a problem. I can not playing video with this source, my error is

Unable to handle format: MPEG, 352x240, FrameRate=29.9, Length=126720 Unable to handle format: mpegaudio, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed, 28000.0 frame rate, FrameSize=32768 bi ts [center] set component: null Exception in trigger: java.lang.NullPointerException at java.awt.Container.addImpl(Container.java:1045) at java.awt.Container.add(Container.java:927) at JMFComponent$_SBECL.onChange(JMFComponent.fx:14) at com.sun.javafx.runtime.location.ObjectVariable.notifyListeners(ObjectVariable.java:142) at com.sun.javafx.runtime.location.ObjectVariable.replaceValue(ObjectVariable.java:104) at com.sun.javafx.runtime.location.ObjectVariable.set(ObjectVariable.java:115) at JMFComponent.set$center(JMFComponent.fx:12) at MyMedia.create(MyMedia.fx:37) at javafx.scene.CustomNode.userInit$(CustomNode.fx:129) at com.sun.javafx.runtime.FXBase.complete$(FXBase.java:56) at Main.javafx$run$(Main.fx:10) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sun.javafx.runtime.provider.GUIRuntimeProvider$1.run(GUIRuntimeProvider.java:65) at com.sun.javafx.tk.swing.SwingToolkit$StartupRoutine.run(SwingToolkit.fx:593) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Thanks for your respond

arman
You should not post follow-up questions as answers, better start a newquestion instead.The "Ask Question" button is in the top right of this page.
sth
Since you asked it as a question (sorry you didn't get any answers), you could also delete this post here, since it's not really helpful to anyone searching for an answer to **this** question.
sth
A: 

Windows users must first define a light weight componente! look at: http://codepad.org/UDXV3hD6

a_user