next up previous
Next: Using Movie Callbacks Up: Displaying and Streaming Movies Previous: Using The Detached Controller

Converting To Full Screen

The FullScreen class provides the capability for converting a screen to full-screen mode and back to normal mode. The QuickTime for Java API allows you to put the specified screen into full screen mode and then use a Java window to fill the screen.

To do this, you use the FullScreenWindow class, which is a subclass of the java.awt.Window object. The FullScreenWindow class internally manages a FullScreen object, and when the show() method is called, it puts the screen into full-screen mode and fills up the screen with an awt.Window. This is very useful because you can get the complete functionality of using a Java AWT Window but in full-screen mode.

The movie is created in a similar fashion as the QTStreamingApplet. The program also creates a menu that allows the user to select a movie and once opened provides a Present Movie menu item to present the movie in full screen mode.

The full code listing is available in the online code examples.

The main parts of the code are as follows:

You present the movie in full screen mode and use the current screen resolution and current movie. The QTCanvas is created using the performance resize flag. This ensures that the movie is displayed at its original size or at a multiple of 2:

FullScreenWindow w = new FullScreenWindow(new FullScreen(),
myPlayMovie);
MoviePlayer mp = new MoviePlayer (myPlayMovie.getMovie());
QTCanvas c = new QTCanvas (QTCanvas.kPerformanceResize, 0.5F, 0.5F);
w.add (c);
w.setBackground (Color.black);

You remove the movie from its current QTCanvas and put the movie into the new canvas of the FullScreenWindow. You do this because a QTDrawable can only draw to a single destination QDGraphics:

myPlayMovie.getCanvas().removeClient();
c.setClient (mp, false);

HideFSWindow is a MouseListener. A MouseListener is installed on both the QTCanvas and the Window. The window is then shown, which will put the window into full-screen mode:

w.show();
HideFSWindow hw = new HideFSWindow (w, myPlayMovie, c);
w.addMouseListener (hw);
c.addMouseListener (hw);

As MoviePlayer object is used to present the movie, this shows just the movie and not a controller. So finally, you start the movie playing:

mp.setRate (1);

When the user presses the mouse, the movie is restored to its previous QTCanvas and the full-screen window is hidden:

public void mousePressed (MouseEvent me) {
try {
c.removeClient();
pm.getCanvas().setClient (pm.getPlayer(), false);
} catch (QTException e) {
e.printStackTrace();
} finally {
w.hide();
}
}

The user must explicitly press the mouse to hide the FullScreenWindow. However, your application could also define an ExtremeCallBack that would automatically hide the FullScreenWindow when the movie is finished playing. Callbacks are discussed in the next section.


next up previous
Next: Using Movie Callbacks Up: Displaying and Streaming Movies Previous: Using The Detached Controller
Dave Marshall
10/4/2001