JMF+JavaFx布局问题

发布于 2024-07-13 06:26:43 字数 2225 浏览 9 评论 0原文

我可以在javafx中创建一个GUI并在JavaFx中调用JMF组件,就像这样

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
        }
    }
}

视频可以在JavaFx gui中播放,但是当我将鼠标光标移动到JMF播放器的控制栏中时,视频窗口将在同时。

有谁知道如何让 JMF 在 JavaFx 中正常工作?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暖阳 2024-07-20 06:26:43

为什么选择 JMF? javafx.scene.media

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

多孤肩上扛 2024-07-20 06:26:43

我有一个解决方案。 在尝试了一些更改之后,将组件 JMFComponent 的属性“disable”设置为“false”。 这可以防止某些包含流的屏幕在其上移动鼠标指针。

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

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
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文