Gostaria de ajuda, pois nao estou conseguindo de maneira nenhuma fazer um script NCL chamar uma XLET através do emulador do Ginga. Vou postar os dois códigos que fiz e gostaria que voces me dissessem o que tenho q acrescentar para para funcionar. Desde já agradeco.
------------------------------------------XLET--------------------------------------------------------
import org.dvb.ui.*;
import java.awt.Font;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.Rectangle;
import java.awt.Toolkit;
import javax.tv.xlet.Xlet;
import javax.tv.xlet.XletContext;
import javax.tv.xlet.XletStateChangeException;
import javax.tv.service.selection.ServiceContextFactory;
import javax.tv.service.selection.ServiceContentHandler;
import javax.tv.media.AWTVideoSize;
import javax.tv.media.AWTVideoSizeControl;
import org.havi.ui.HDefaultTextLayoutManager;
import org.havi.ui.HScene;
import org.havi.ui.HSceneFactory;
import org.havi.ui.HScreen;
import org.havi.ui.HStaticText;
import org.havi.ui.event.HRcEvent;
import javax.media.Player;
import org.havi.ui.HGraphicButton;
public class VestibularXlet implements Xlet, KeyListener {
private XletContext contexto;
private HScene scene;
private HStaticText label;
private HStaticText indicador;
private MenuPrincipal menuPrincipal;
private HGraphicButton botao;
public VestibularXlet() {
}
public void initXlet(XletContext xletContext) throws XletStateChangeException {
System.out.println("initXlet()");
contexto = xletContext;
String botao = "";
String inicial = "Inicia Aplicação";
HSceneFactory hsceneFactory = HSceneFactory.getInstance();
scene = hsceneFactory.getFullScreenScene(HScreen.getDefaultHScreen().getDefaultHGraphicsDevice());
//DEFINE O TAMANHO DA TELA DO FRAME INFERIOR
scene.setSize(1024, 576);
scene.setLayout(null);
scene.addKeyListener(this);
label = new HStaticText(inicial, 60, 520, 260, 40, new Font("verdana", Font.BOLD, 18), DVBColor.black, new DVBColor(255,255,253,230), new HDefaultTextLayoutManager());
indicador = new HStaticText(inicial, 20, 525, 30, 30, new Font("Arial", Font.BOLD, 1), DVBColor.red, new DVBColor(255,0,0,255), new HDefaultTextLayoutManager());
scene.add(indicador);
scene.add(label);
/* MediaTracker tracker = new MediaTracker(this);
Image ucg_splash = Toolkit.getDefaultToolkit().getImage("ucg_splash.png");
tracker.addImage(ucg_splash, 0);
splash = new HGraphicButton(ucg_splash, 0, 400, 850, 200);
this.add(splash);*/
scene.validate();
scene.setVisible(true);
scene.requestFocus();
}
public void startXlet() throws XletStateChangeException {
System.out.println("startXlet()");
}
public void pauseXlet() {
}
//APOS SAIR DA APLICAÇÃO REFAZ A TELA COM O TAMANHO DEFINIDO ABAIXO
public void destroyXlet(boolean flag) throws XletStateChangeException {
System.out.println("destroyXlet");
if (scene != null) {
scene.setVisible(false);
scene.removeAll();
scene = null;
}
Rectangle source = new Rectangle(0, 0, 1024, 576);
Rectangle destination = new Rectangle(0, 0, 1024, 576);
resize(new AWTVideoSize(source, destination));
contexto.notifyDestroyed();
}
public void keyTyped(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
}
//APOS ClICAR BOTÂO VERMELHO DO CONTROLE, REDIMENSIONA PARA MENOS A TELA DO VIDEO
public void keyPressed(KeyEvent e) {
if (e.getKeyChar()==HRcEvent.VK_COLORED_KEY_0) {
label.setVisible(false);
indicador.setVisible(false);
Rectangle source = new Rectangle(0, 0, 775, 576);
//Dimensões do Tamanho da tela CANAL
Rectangle destination = new Rectangle(0,0,775,436);
resize(new AWTVideoSize(source, destination));
menuPrincipal = new MenuPrincipal(775,0,249,1024, scene);
scene.add(menuPrincipal);
scene.repaint();
menuPrincipal.transferFocus();
}
else if (e.getKeyChar()==HRcEvent.VK_ENTER) {
System.out.println(e.getSource());
//if (e.getSource() == botao)
// System.out.println("botao1");
}
else if (e.getKeyChar()==HRcEvent.VK_COLORED_KEY_2) {
menuPrincipal.transferFocus();
}
else if (e.getKeyChar()==HRcEvent.VK_ESCAPE) {
try {
destroyXlet(true);
}
catch(XletStateChangeException xletstatechangeexception) {
}
}
}
public void resize(AWTVideoSize size) {
ServiceContextFactory serviceContextFactory = null;
javax.tv.service.selection.ServiceContext serviceContext = null;
try {
serviceContextFactory = ServiceContextFactory.getInstance();
serviceContext = serviceContextFactory.getServiceContext(contexto);
} catch (Exception ex) {
ex.printStackTrace();
}
if (serviceContext != null) {
ServiceContentHandler[] serviceContentHandler = serviceContext.getServiceContentHandlers();
Player player = null;
if (serviceContentHandler.length > 0) {
player = (Player) serviceContentHandler[0];
}
if (player != null) {
AWTVideoSizeControl awtVideoSizeControl = (AWTVideoSizeControl) player.getControl("javax.tv.media.AWTVideoSizeControl");
awtVideoSizeControl.setSize(size);
System.out.println("video resized using " + size);
}
}
}
}
----------------------------------------NCL------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<ncl xsi:schemaLocation="http://www.ncl.org.br/NCL3.0/EDTVProfile http://www.ncl.org.br/NCL3.0/profiles/NCL30EDTV.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.ncl.org.br/NCL3.0/EDTVProfile" id="newDocument1">
<head>
<connectorBase>
<importBase documentURI="composerConnectorBase.conn" alias="connBase"/>
</connectorBase>
<regionBase>
<region left="-2" top="1" width="1920" height="1080" id="rgTV">
<region left="180" top="112" width="800" height="600" id="rgVideo" zIndex="1"/>
<region left="180" top="714" width="30" height="30" id="rgBotaoInterativo" zIndex="2"/>
<region left="180" top="652" width="166" height="60" id="rgOpcao1" zIndex="2"/>
<region left="345" top="652" width="160" height="60" id="rgOpcao2" zIndex="2"/>
<region left="503" top="652" width="160" height="60" id="rgOpcao3" zIndex="2"/>
<region top="652" left="661" width="160" height="60" id="rgOpcao4" zIndex="2"/>
<region left="820" top="652" width="160" height="60" id="rgOpcao5" zIndex="2"/>
<region left="0" top="112" width="180" height="601" id="rgInformacao"/>
<region left="222" top="714" width="30" height="30" id="rgBotaoXlet"/>
<region left="2" top="2" width="980" height="112" id="rgBanner"/>
<region left="980" top="1" width="303" height="711" id="rgXlets"/>
<region left="264" top="714" width="30" height="30" id="rgBotaoOff"/>
<region left="308" top="714" width="30" height="30" id="rgBotaoMtv"/>
</region>
</regionBase>
<descriptorBase>
<descriptor region="rgVideo" id="dVideo"/>
<descriptor region="rgOpcao1" id="dOpcao1" focusIndex="1" moveRight="2" focusBorderWidth="-2" focusBorderColor="red"/>
<descriptor region="rgOpcao2" id="dOpcao2" focusIndex="2" moveRight="3" moveLeft="1" focusBorderWidth="-2" focusBorderColor="red"/>
<descriptor region="rgOpcao3" id="dOpcao3" focusIndex="3" moveRight="4" moveLeft="2" focusBorderWidth="-2" focusBorderColor="red"/>
<descriptor region="rgOpcao4" id="dOpcao4" focusIndex="4" moveRight="5" moveLeft="3" focusBorderWidth="-2" focusBorderColor="red"/>
<descriptor region="rgOpcao5" id="dOpcao5" focusIndex="5" moveLeft="4" focusBorderWidth="-2" focusBorderColor="red"/>
<descriptor region="rgInformacao" id="dInformacao"/>
<descriptor id="dInfcabecalho"/>
<descriptor region="rgBotaoInterativo" id="dBotaoInterativo"/>
<descriptor region="rgBotaoXlet" id="dBotaoXlet"/>
<descriptor region="rgBanner" id="dBanner"/>
<descriptor region="rgXlets" id="dXlets"/>
<descriptor region="rgBotaoOff" id="dBotaoOff"/>
<descriptor region="rgBotaoMtv" id="dBotaoMtv"/>
</descriptorBase>
</head>
<body>
<media descriptor="dVideo" src="Y:/Rock/The White Stripes - Seven Nation Army.mpeg" type="video/mpeg" id="video"/>
<media descriptor="dBotaoInterativo" src="C:\Users\Daniel\Desktop\ProjetoClipe/media/botaointerativo.gif" type="image/gif" id="botaointerativo"/>
<media descriptor="dOpcao2" src="C:\Users\Daniel\Desktop\ProjetoClipe/media/biografia.gif" type="image/gif" id="biografia"/>
<media descriptor="dOpcao1" src="C:\Users\Daniel\Desktop\ProjetoClipe/media/whitestripes.gif" type="image/gif" id="whitestripes"/>
<media descriptor="dOpcao3" src="C:\Users\Daniel\Desktop\ProjetoClipe/media/discografia.gif" type="image/gif" id="discografia"/>
<media descriptor="dOpcao4" src="C:\Users\Daniel\Desktop\ProjetoClipe/media/curiosidades.gif" type="image/gif" id="curiosidades"/>
<media descriptor="dOpcao5" src="C:\Users\Daniel\Desktop\ProjetoClipe/media/opiniao.gif" type="image/gif" id="opiniao"/>
<media descriptor="dInformacao" src="C:\Users\Daniel\Desktop\ProjetoClipe/media/menuwhite.gif" type="image/gif" id="menuwhitestripes"/>
<media descriptor="dInformacao" src="C:\Users\Daniel\Desktop\ProjetoClipe/media/menubiografia.gif" type="image/gif" id="menubiografia"/>
<media descriptor="dInformacao" src="C:\Users\Daniel\Desktop\ProjetoClipe/media/menudiscografia.gif" type="image/gif" id="menudiscografia"/>
<media descriptor="dInformacao" src="C:\Users\Daniel\Desktop\ProjetoClipe/media/menucuriosidades.gif" type="image/gif" id="menucuriosidades"/>
<media descriptor="dInformacao" src="C:\Users\Daniel\Desktop\ProjetoClipe/media/menuopiniao.gif" type="image/gif" id="menuopiniao"/>
<media descriptor="dBotaoInterativo" src="C:\Users\Daniel\Desktop\ProjetoClipe/media/botaovolta.gif" type="image/gif" id="botaointerativovolta"/>
<media descriptor="dBotaoXlet" src="media/botaoxlet.gif" type="image/gif" id="botaoxlet"/>
<media descriptor="dBanner" src="media/banner.jpg" type="image/gif" id="banner"/>
<media descriptor="dXlets" src="media/bannerxlet.jpg" type="image/gif" id="bannerxlet"/>
<media descriptor="dBotaoOff" src="media/botaomakingoff.gif" type="image/gif" id="botaomakingoff"/>
<media descriptor="dBotaoMtv" src="media/botaomtv.gif" type="image/gif" id="botaomtv"/>
<port component="video" id="port_newDocument1_video"/>
<link xconnector="connBase#onBeginStart" id="comecavideo">
<bind role="onBegin" component="video"/>
<bind role="start" component="botaointerativo"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciomenuwhite">
<bind role="onSelection" component="botaointerativo">
<bindParam name="keyCode" value="GREEN"/>
</bind>
<bind role="stop" component="botaointerativo"/>
<bind role="start" component="whitestripes"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciobanner">
<bind role="onSelection" component="botaointerativo">
<bindParam name="keyCode" value="GREEN"/>
</bind>
<bind role="stop" component="botaointerativo"/>
<bind role="start" component="banner"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciobotaomakingoff">
<bind role="onSelection" component="botaointerativo">
<bindParam name="keyCode" value="GREEN"/>
</bind>
<bind role="stop" component="botaointerativo"/>
<bind role="start" component="botaomakingoff"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciobotaomtv">
<bind role="onSelection" component="botaointerativo">
<bindParam name="keyCode" value="GREEN"/>
</bind>
<bind role="stop" component="botaointerativo"/>
<bind role="start" component="botaomtv"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciobannerxlet">
<bind role="onSelection" component="botaointerativo">
<bindParam name="keyCode" value="GREEN"/>
</bind>
<bind role="stop" component="botaointerativo"/>
<bind role="start" component="bannerxlet"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="voltamenu">
<bind role="onSelection" component="botaointerativovolta">
<bindParam name="keyCode" value="RED"/>
</bind>
<bind role="stop" component="botaointerativovolta"/>
<bind role="start" component="botaointerativo"/>
<bind role="stop" component="botaoxlet"/>
<bind role="stop" component="banner"/>
<bind role="stop" component="bannerxlet"/>
<bind role="stop" component="botaomakingoff"/>
<bind role="stop" component="botaomtv"/>
<bind role="stop" component="whitestripes"/>
<bind role="stop" component="biografia"/>
<bind role="stop" component="discografia"/>
<bind role="stop" component="opiniao"/>
<bind role="stop" component="curiosidades"/>
<bind role="stop" component="menuwhitestripes"/>
<bind role="stop" component="menubiografia"/>
<bind role="stop" component="menudiscografia"/>
<bind role="stop" component="menucuriosidades"/>
<bind role="stop" component="menuopiniao"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciobotaovolta">
<bind role="onSelection" component="botaointerativo">
<bindParam name="keyCode" value="GREEN"/>
</bind>
<bind role="stop" component="botaointerativo"/>
<bind role="start" component="botaointerativovolta"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciomenbiografia">
<bind role="onSelection" component="botaointerativo">
<bindParam name="keyCode" value="GREEN"/>
</bind>
<bind role="stop" component="botaointerativo"/>
<bind role="start" component="biografia"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciomenudiscografia">
<bind role="onSelection" component="botaointerativo">
<bindParam name="keyCode" value="GREEN"/>
</bind>
<bind role="stop" component="botaointerativo"/>
<bind role="start" component="discografia"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciomenucuriosidades">
<bind role="onSelection" component="botaointerativo">
<bindParam name="keyCode" value="GREEN"/>
</bind>
<bind role="stop" component="botaointerativo"/>
<bind role="start" component="curiosidades"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciomenuopiniao">
<bind role="onSelection" component="botaointerativo">
<bindParam name="keyCode" value="GREEN"/>
</bind>
<bind role="stop" component="botaointerativo"/>
<bind role="start" component="opiniao"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciobotaoxlet">
<bind role="onSelection" component="botaointerativo">
<bindParam name="keyCode" value="GREEN"/>
</bind>
<bind role="stop" component="botaointerativo"/>
<bind role="start" component="botaoxlet"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciomenuwhitestripes">
<bind role="onSelection" component="whitestripes">
<bindParam name="keyCode" value="VK_ENTER"/>
</bind>
<bind role="stop" component="menubiografia"/>
<bind role="stop" component="menudiscografia"/>
<bind role="stop" component="menucuriosidades"/>
<bind role="stop" component="menuopiniao"/>
<bind role="start" component="menuwhitestripes"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciomenudiscografia">
<bind role="onSelection" component="discografia">
<bindParam name="keyCode" value="VK_ENTER"/>
</bind>
<bind role="stop" component="menubiografia"/>
<bind role="stop" component="menuwhitestripes"/>
<bind role="stop" component="menucuriosidades"/>
<bind role="stop" component="menuopiniao"/>
<bind role="start" component="menudiscografia"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciomenubiografia">
<bind role="onSelection" component="biografia">
<bindParam name="keyCode" value="VK_ENTER"/>
</bind>
<bind role="stop" component="menuwhitestripes"/>
<bind role="stop" component="menudiscografia"/>
<bind role="stop" component="menucuriosidades"/>
<bind role="stop" component="menuopiniao"/>
<bind role="start" component="menubiografia"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciomenucuriosidades">
<bind role="onSelection" component="curiosidades">
<bindParam name="keyCode" value="VK_ENTER"/>
</bind>
<bind role="stop" component="menubiografia"/>
<bind role="stop" component="menudiscografia"/>
<bind role="stop" component="menuwhitestripes"/>
<bind role="stop" component="menuopiniao"/>
<bind role="start" component="menucuriosidades"/>
</link>
<link xconnector="connBase#onKeySelectionStartNStopN" id="iniciomenuopiniao">
<bind role="onSelection" component="opiniao">
<bindParam name="keyCode" value="VK_ENTER"/>
</bind>
<bind role="stop" component="menubiografia"/>
<bind role="stop" component="menudiscografia"/>
<bind role="stop" component="menuwhitestripes"/>
<bind role="stop" component="menucuriosidades"/>
<bind role="start" component="menuopiniao"/>
</link>
</body>
</ncl>
Autor: Daniel Alves Cruz
1Um comentário