Question

I tried to find variants to draw one image over one VideoComponent and apparently not is possible!. What I do is to display an image on pause video playback and add a back button to a Form.

The problem is that the image is never painted over the VideoComponent control

Part of the code below:

//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();
        }            
    }    

}    
Was it helpful?

Solution

This is an MMAPI issue unrelated to LWUIT. By default the video will always be on top.

MMAPI's JSR 234 offers support for something like that but it requires delving deep into the media implementation specific for MIDP and specific for phone devices.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top