1

我试图找到变体来在一个 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();
        }            
    }    

}    
4

1 回答 1

2

这是一个与 LWUIT 无关的 MMAPI 问题。默认情况下,视频将始终位于顶部。

MMAPI 的 JSR 234 提供了类似的支持,但它需要深入研究特定于 MIDP 和特定于电话设备的媒体实现。

于 2012-02-23T05:09:17.657 回答