JMF+JavaFx布局问题
我可以在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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么选择 JMF? javafx.scene.media
Why JMF? There is neat API under javafx.scene.media
我有一个解决方案。 在尝试了一些更改之后,将组件 JMFComponent 的属性“disable”设置为“false”。 这可以防止某些包含流的屏幕在其上移动鼠标指针。
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.