home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-01-28 | 3.4 KB | 128 lines |
- // Copyright (c) Oracle Corporation 1997. All Rights Reserved.
- //
- // Package oracle.ovc - Oracle Video Client for Java
- //
- // Simple.java - This example demonstrates the basic Player object.
-
- // Sun JDK Imports
- import java.awt.*;
- import java.awt.event.*;
-
-
- // Oracle Video Client Imports
- import oracle.ovc.PlayerFactory;
- import oracle.ovc.PlayerException;
- import oracle.ovc.Player;
-
-
- public class Simple
- {
- static Player player = null;
- static Component playerUI = null;
- static Frame playerframe = null;
-
- static String m_MediaFile = "/mds/video/ovs_mpg1_2048k.mpi";
- static int m_Width = 360;
- static int m_Height = 311;
-
- public static void main (String args[])
- {
- Simple app = new Simple ();
- playerframe = new PlayerFrame ("OVPlayer", m_Width, m_Height);
-
- app.addPlayer();
-
- app.loadMediaFile();
-
- } // end of main
-
-
- public void addPlayer()
- {
- // Create a player object.
- try {
- player = PlayerFactory.getPlayer ();
- }
- catch ( UnsatisfiedLinkError e ) {
- System.out.println(e.getMessage());
- }
- catch ( PlayerException e ) {
- System.out.println("Unable to create a Player object: " + e);
- }
-
- // Create the visual playback component of the player object.
- try {
- playerUI = player.getPlayerUI ();
- }
- catch ( PlayerException e ) {
- System.out.println("exception in getPlayerUI: " + e);
- }
-
- // Add the visual component of the player object
- // to the frame.
- playerframe.add (playerUI);
- playerframe.show ();
-
- } // end of addPlayer
-
-
- public void loadMediaFile()
- {
- // Load and prepare the default video for playback
- // with default stream options.
- try {
- player.load (m_MediaFile, null);
- }
- catch ( PlayerException e ) {
- System.out.println("Could not load content: " + e);
- }
- } // end of initial_load
-
- } // end of Simple class
-
-
- class PlayerFrame extends Frame
- {
- public PlayerFrame (String title, int m_Width, int m_Height)
- {
- super (title);
-
- // Register a Windowlistener after creating the frame,
- // the listener is required to exit properly from the app.
- addWindowListener(new PFAdapter());
-
- setSize (m_Width, m_Height);
-
- } // end of constructor
-
- } // end of class
-
-
- class PFAdapter extends WindowAdapter
- {
- public void windowClosing(WindowEvent event)
- {
- System.out.println("Shutting down the java client ...");
-
- if (Simple.player != null)
- {
- try {
- System.out.println("Player state before exiting: " + Simple.player.getState());
-
- // Unload the video before exiting, thereby
- // releasing any resources associated with the current stream.
- Simple.player.unload ();
- Simple.player.term ();
- }
- catch (PlayerException e) {
- System.out.println("exception while unloading: " + e);
- }
- }
-
- System.exit(0);
-
- } // end of windowClosing
-
- } // end of PFAdapter
-
-