UOMaskTableを取得するサンプルコード。
本プログラムでは、UOMaskTable更新イベントを取得し、Maskの状態が変更されたUOは赤色で表示する。
Main.java
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Graphics;
import java.util.HashMap;
import javax.media.Manager;
import javax.media.Player;
import javax.tv.xlet.Xlet;
import javax.tv.xlet.XletContext;
import org.bluray.media.UOMaskTableChangedEvent;
import org.bluray.media.UOMaskTableControl;
import org.bluray.media.UOMaskTableListener;
import org.bluray.media.UOMaskedEvent;
import org.bluray.net.BDLocator;
import org.davic.media.MediaLocator;
import org.havi.ui.HScene;
import org.havi.ui.HSceneFactory;
import org.havi.ui.HScreen;
public class Main extends Component implements Xlet, UOMaskTableListener {
UOMaskTableControl umtc;
boolean[] curr, prev;
HashMap map = new HashMap();
public void initXlet(XletContext xc){
try {
map.put(new Integer( UOMaskTableControl.ACTIVATE_BUTTON_MASK_INDEX ), "ACTIVATE_BUTTON_MASK");
map.put(new Integer( UOMaskTableControl.ANGLE_CHANGE_MASK_INDEX ), "ANGLE_CHANGE_MASK");
map.put(new Integer( UOMaskTableControl.AUDIO_CHANGE_MASK_INDEX ), "AUDIO_CHANGE_MASK");
map.put(new Integer( UOMaskTableControl.BACKWARD_PLAY_MASK_INDEX ), "BACKWARD_PLAY_MASK");
map.put(new Integer( UOMaskTableControl. CHAPTER_SEARCH_MASK_INDEX ), "CHAPTER_SEARCH_MASK");
map.put(new Integer( UOMaskTableControl.FORWARD_PLAY_MASK_INDEX ), "FORWARD_PLAY_MASK");
map.put(new Integer( UOMaskTableControl.MOVE_DOWN_SELECTED_BUTTON_MASK_INDEX ), "MOVE_DOWN_SELECTED_BUTTON_MASK");
map.put(new Integer( UOMaskTableControl.MOVE_LEFT_SELECTED_BUTTON_MASK_INDEX ), "MOVE_LEFT_SELECTED_BUTTON_MASK");
map.put(new Integer( UOMaskTableControl.MOVE_RIGHT_SELECTED_BUTTON_MASK_INDEX ), "MOVE_RIGHT_SELECTED_BUTTON_MASK");
map.put(new Integer( UOMaskTableControl.MOVE_UP_SELECTED_BUTTON_MASK_INDEX ), "MOVE_UP_SELECTED_BUTTON_MASK");
map.put(new Integer( UOMaskTableControl.PAUSE_ON_MASK_INDEX ), "PAUSE_ON_MASK");
map.put(new Integer( UOMaskTableControl.PG_TEXTST_CHANGE_MASK_INDEX ), "PG_TEXTST_CHANGE_MASK");
map.put(new Integer( UOMaskTableControl.PG_TEXTST_ENABLE_DISABLE_MASK_INDEX ), "PG_TEXTST_ENABLE_DISABLE_MASK");
map.put(new Integer( UOMaskTableControl.PIP_PG_TEXTST_CHANGE_MASK_INDEX ), "PIP_PG_TEXTST_CHANGE_MASK");
map.put(new Integer( UOMaskTableControl.POPUP_OFF_MASK_INDEX ), "POPUP_OFF_MASK");
map.put(new Integer( UOMaskTableControl. POPUP_ON_MASK_INDEX ), "POPUP_ON_MASK");
map.put(new Integer( UOMaskTableControl.PRIMARY_AUDIO_CHANGE_MASK_INDEX ), "PRIMARY_AUDIO_CHANGE_MASK");
map.put(new Integer( UOMaskTableControl.RESUME_MASK_INDEX ), "RESUME_MASK");
map.put(new Integer( UOMaskTableControl.SECONDARY_AUDIO_CHANGE_MASK_INDEX ), "SECONDARY_AUDIO_CHANGE_MASK");
map.put(new Integer( UOMaskTableControl.SECONDARY_AUDIO_ENABLE_DISABLE_MASK_INDEX ), "SECONDARY_AUDIO_ENABLE_DISABLE_MASK");
map.put(new Integer( UOMaskTableControl.SECONDARY_VIDEO_CHANGE_MASK_INDEX ), "SECONDARY_VIDEO_CHANGE_MASK");
map.put(new Integer( UOMaskTableControl.SECONDARY_VIDEO_ENABLE_DISABLE_MASK_INDEX ), "SECONDARY_VIDEO_ENABLE_DISABLE_MASK");
map.put(new Integer( UOMaskTableControl.SELECT_AND_ACTIVATE_MASK_INDEX ), "SELECT_AND_ACTIVATE_MASK");
map.put(new Integer( UOMaskTableControl.SELECT_BUTTON_MASK_INDEX ), "SELECT_BUTTON_MASK");
map.put(new Integer( UOMaskTableControl.SKIP_BACK_TO_PREVIOUS_POINT_MASK_INDEX ), "SKIP_BACK_TO_PREVIOUS_POINT_MASK");
map.put(new Integer( UOMaskTableControl.SKIP_TO_NEXT_POINT_MASK_INDEX ), "SKIP_TO_NEXT_POINT_MASK");
map.put(new Integer( UOMaskTableControl.STILL_OFF_MASK_INDEX ), "STILL_OFF_MASK");
map.put(new Integer( UOMaskTableControl.STOP_MASK_INDEX ), "STOP_MASK");
map.put(new Integer( UOMaskTableControl.TIME_SEARCH_MASK_INDEX ), "TIME_SEARCH_MASK");
HScene hs= HSceneFactory.getInstance().getFullScreenScene(
HScreen.getDefaultHScreen().getDefaultHGraphicsDevice());
setBounds(hs.getBounds());
setFont(new Font(null, Font.BOLD, 32));
hs.setBackgroundMode(HScene.BACKGROUND_FILL);
hs.add(this);
hs.setVisible(true);
Player player = Manager.createPlayer(new MediaLocator(new BDLocator("bd://1.PLAYLIST:00000")));
// UOMaskTableControlを取得
umtc = (UOMaskTableControl) player.getControl("org.bluray.media.UOMaskTableControl");
umtc.addUOMaskTableEventListener(this);
player.start();
} catch (Exception e){
}
}
public void startXlet(){}
public void pauseXlet(){ }
public void destroyXlet(boolean unconditional){ }
public void paint(Graphics g ){
int x=100, y=50;
for( int i = 0; i < curr.length; i++ ){
String name = (String)map.get( new Integer(i) );
if( null != name ){
if( curr[i] == prev[i] ){
g.setColor(Color.white);
} else {
g.setColor(Color.red);
}
g.drawString( name+":"+curr[i], x, y ); y += 35;
}
}
}
// リスナーを実装
public void receiveUOMaskTableChangedEvent(UOMaskTableChangedEvent e) {
prev = curr;
curr = umtc.getMaskedUOTable(); repaint();
}
public void receiveUOMaskedEvent(UOMaskedEvent e) {}
}