-
Notifications
You must be signed in to change notification settings - Fork 0
Starting Guide
In 2008, Chihiro Saito, a developer for Sun Microsystems, created a BD-J plugin for Netbeans. You could previously download it here, but the old Plugins site has been deleted. With some minor tweaks, it could be used today and took care of a lot of stuff for you.
I have not been able to get the plug-in working again, but I was able to transfer the example project I created to IntelliJ, and have been using its ant file to work with.
Some essential tools apparently got reorganized during the move from Java 7 to Java 8. You will need to have JDK7 or earlier somewhere on your computer. I have edited the Ant build.xml to use VLC and take this into account.
You need to fill in the location of your JDK7 or earlier here:
<property name="OldJavaLocation" value=" "/>
In order for the free software VLC to be able to play Blu-Ray, you require libbluray. Please refer to VLC guides to find out more. In order for VLC to play your self-crafted Blu-Ray Java project, you need to have a video file running.
Paste the contents of this directory in the /dist/DiscImage/BDMV/
directory of your project.
Finally, replace the HelloTVXlet.java
with this file.
You should see this in VLC when you run the project:
VLC unfortunately only recognizes a few of the many buttons you would find on a typical Blu-Ray Player remote. That's why we're going to focus on the arrow keys and the enter key for now.
First you need to make your Xlet implement UserEventListener
.
Add the following to your initXlet()
:
UserEventRepository repository = new UserEventRepository("Repository");
repository.addAllArrowKeys();
repository.addKey(HRcEvent.VK_ENTER);
EventManager.getInstance().addUserEventListener((UserEventListener) this, repository);
Then add the userEventReceived
method to your Xlet.
public void userEventReceived(UserEvent e) {
//The magic happens here.
}
An example implementation expects the Xlet to have a member variable private int counter = 0
. We will increment and decrement this counter with the left and right arrow keys, and redraw the gui in a different color depending on this counter.
public void userEventReceived(UserEvent e) {
if (e.getCode() == HRcEvent.VK_LEFT) {
counter -= 20;
} else if (e.getCode() == HRcEvent.VK_RIGHT) {
counter += 20;
}
if (counter > 250 || counter < 0) {
counter = 0;
}
scene.remove(gui);
gui = new Container() {
public void paint(Graphics graphics) {
graphics.setFont(font);
graphics.setColor(new Color(120, 120, counter));
graphics.fillRect(150, 150, getWidth() - 300, getHeight() - 300);
graphics.setColor(new Color(200, 200, 200));
int message_width = graphics.getFontMetrics().stringWidth(message);
graphics.drawString(message, (getWidth() - message_width) / 2, 500);
}
};
scene.add(gui, BorderLayout.CENTER);
gui.setSize(1920, 1080); // BD screen size
scene.add(gui, BorderLayout.CENTER);
scene.validate();
}
This won't work:
Image img = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/randomimage.png"));
graphics.drawImage(img,150, 150, null);
Toolkit is threaded. I've been spoiled by modern Java, so I didn't really get that. But it was fortunately explained to me by our Japanese predecessors.
Image img = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/randomimage.png"));
MediaTracker tracker= new MediaTracker(this);
tracker.addImage(img, 0);
try{
tracker.waitForAll();
}
catch (Exception e){
}
graphics.drawImage(img,150, 150, null);
“Blu-ray Disc”, “Blu-ray” and “Blu-ray Disc” logo are trademarks of the Blu-ray Disc Association.