1

1 つの VideoComponent に 1 つの画像を描画するバリアントを見つけようとしましたが、明らかに不可能です!. 私がやっていることは、ビデオ再生の一時停止時に画像を表示し、フォームに戻るボタンを追加することです。

問題は、画像が 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 に答える