home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-06-23 | 2.1 KB | 73 lines |
- /*
- * QuickTime for Java SDK Sample Code
-
- Usage subject to restrictions in SDK License Agreement
- * Copyright: © 1996-1999 Apple Computer, Inc.
-
- */
- import java.applet.Applet;
- import java.awt.*;
- import java.io.*;
-
- import quicktime.*;
- import quicktime.io.QTFile;
-
- import quicktime.app.QTFactory;
- import quicktime.app.display.*;
- import quicktime.app.image.ImageDrawer; // for exceptions
-
- public class QTSimpleApplet extends Applet {
- private Drawable myQTContent;
- private QTCanvas myQTCanvas;
-
- public void init () {
- try {
- // this is a workaround required by a bug in the loading
- // mechanism of applets using the JavaPlugin on Netscape on Win
- if (QTSession.isInitialized() == false)
- QTSession.open();
-
- // set up a QTCanvas which will disply its content
- // at its original size of smaller and centered in the space given
- // to the QTCanvas when the applet is layed out
- setLayout (new BorderLayout());
- myQTCanvas = new QTCanvas (QTCanvas.kInitialSize, 0.5F, 0.5F);
- add (myQTCanvas, "Center");
-
- QTFile file = new QTFile (getCodeBase().getFile() + getParameter("file"));
- myQTContent = QTFactory.makeDrawable (file);
- } catch (QTException qtE) {
- // something wrong with the content but QT itself is OK
- if (QTSession.isInitialized())
- myQTContent = ImageDrawer.getQTLogo();
- else
- throw new RuntimeException (qtE.getMessage());
- } catch (FileNotFoundException fnfE) {
- myQTContent = ImageDrawer.getQTLogo();
-
- } catch (IOException ioE) {
- // the IOException would occur as a violation of
- // java security settings on the user machine - throw it again
- throw new SecurityException (ioE.getMessage());
- }
- }
-
- public void start () {
- try { // if QT was not successfully initialized the QTCanvas will be null
- if (myQTCanvas != null)
- myQTCanvas.setClient (myQTContent, true);
- } catch (QTException e) {
- e.printStackTrace();
- }
- }
-
- public void stop () {
- if (myQTCanvas != null)
- myQTCanvas.removeClient();
- }
-
- public void destroy () {
- QTSession.close();
- }
- }
-