我试图找到在一个 VideoComponent 上绘制一张图像的变体,但显然不可能!。我所做的是在暂停视频播放时显示图像并向表单添加后退按钮。
问题是图像永远不会绘制在 VideoComponent 控件上
部分代码如下:
//Attributes
VideoComponent vc;
Player player;
Image imgPause;
//Constructor for video player class
public VideoPlayer(String filename)
{
pauseImg = Image.createImage("/pause.png");
if(pauseImg == null)
Log.p("ERROR, VideoPlayer pauseImg is null!!");
vc = VideoComponent.createVideoPeer(fileName);
player = (Player) vc.getNativePeer();
if(vc != null){
vc.setFullScreen(true);
vc.playInNativePlayer();
start();
setLayout(new BorderLayout());
Container container = new Container(new FlowLayout());
Button backButton = new Button("back");
backButton.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent ae) {
closeForm();
}
});
container.addComponent(backButton);
addComponent(BorderLayout.CENTER, vc);
addComponent(BorderLayout.EAST, container);
}
final public void start() {
try {
if(vc != null) {
player.realize();
player.prefetch();
vc.start();
}
} catch(Exception ex) {
Log.p(ex.getMessage());
}
}
public void paint(Graphics g) {
super.paint(g);
if(!isPlaying())
{
int imgWidth = pauseImg.getWidth();
int imgHeight = pauseImg.getHeight();
Log.p("pauseImg.width() = " + imgWidth);
g.drawImage(pauseImg, getWidth()/2 - imgWidth/2 , getHeight()/2 - imgHeight/2);
}
}
public void pointerReleased(int x, int y) {
super.pointerReleased(x, y);
Log.p("VideoPlayer.pointerReleased ");
if(vc != null) {
if(isPlaying()){
vc.stop();
repaint();
}
else {
vc.start();
repaint();
}
}
}
最佳答案
这是与 LWUIT 无关的 MMAPI 问题。默认情况下,视频将始终位于顶部。
MMAPI 的 JSR 234 提供了对类似内容的支持,但它需要深入研究特定于 MIDP 和特定于电话设备的媒体实现。
关于java - 如何使用 LWUIT 框架在 VideoComponent 控件上绘制图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9383456/