Come disegnare un'immagine su un controllo videocomponente usando Lwuit Framework?
Domanda
Ho provato a trovare varianti per disegnare un'immagine su un videocomponente e apparentemente non è possibile!. Quello che faccio è visualizzare un'immagine sulla riproduzione video di pausa e aggiungere un pulsante Indietro a un modulo.
Il problema è che l'immagine non viene mai dipinta sul controllo videocomponente
Parte del codice seguente:
//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();
}
}
}
Soluzione
Questo è un problema MMAPI non correlato a Lwuit. Per impostazione predefinita il video sarà sempre in cima.
JSR 234 di MMAPI offre supporto per qualcosa del genere, ma richiede di approfondire l'implementazione dei media specifici per MIDP e specifico per i dispositivi telefonici.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow