001package ca.bc.webarts.tools; 002 003import java.awt.*; 004import java.awt.event.*; 005import javax.media.*; 006 007 008/** 009 * Description of the Class 010 * 011 * @author tgutwin 012 */ 013public class VideoViewer 014{ 015 /** 016 * Description of the Method 017 * 018 * @param arg Description of the Parameter 019 */ 020 public static void main( String arg[] ) 021 { 022 VideoViewerFrame pp = new VideoViewerFrame( arg[0] ); 023 pp.setVisible( true ); 024 pp.addWindowListener( 025 new WindowAdapter() 026 { 027 public void windowClosing( WindowEvent we ) 028 { 029 System.exit( 0 ); 030 } 031 } ); 032 } 033} 034 035 036/* 037 * Install Java Media Frame Work 038 * set path=c:\jdk1.3\bin;c:\progra~1\jmf2.1.1e\bin this is an example 039 * Run as 040 * javac VideoViewer.java 041 * java VideoViewer file:///c:\\sample1.mpeg 042 */ 043/** 044 * Description of the Class 045 * 046 * @author tgutwin 047 */ 048class VideoViewerFrame extends Frame implements ControllerListener 049{ 050 051 052 /** Description of the Field */ 053 Player player; 054 /** Description of the Field */ 055 MediaLocator locator; 056 /** Description of the Field */ 057 String path; 058 /** Description of the Field */ 059 Panel panel; 060 /** Description of the Field */ 061 String filepath = null; 062 063 064 /** 065 * Constructor for the VideoViewer object 066 * 067 * @param path1 Description of the Parameter 068 */ 069 public VideoViewerFrame( String path1 ) 070 { 071 filepath = path1; 072 panel = new Panel(); 073 panel.setLayout( new BorderLayout() ); 074 add( panel ); 075 setVisible( true ); 076 try 077 { 078 locator = new MediaLocator( filepath ); 079 player = Manager.createPlayer( locator ); 080 player.addControllerListener( this ); 081 player.start(); 082 } 083 catch ( Exception e ) 084 { 085 System.out.println( e.getMessage() ); 086 } 087 } 088 089 090 /** 091 * Description of the Method 092 * 093 * @param ce Description of the Parameter 094 */ 095 public void controllerUpdate( ControllerEvent ce ) 096 { 097 Component vc; 098 Component cc; 099 int w = 400; 100 int h = 400; 101 int h1 = 10; 102 if ( ce instanceof RealizeCompleteEvent ) 103 { 104 vc = player.getVisualComponent(); 105 Dimension size = vc.getPreferredSize(); 106 w = size.width; 107 h = size.height; 108 panel.add( "Center", vc ); 109 cc = player.getControlPanelComponent(); 110 Dimension size1 = cc.getPreferredSize(); 111 h1 = size1.height; 112 panel.add( "South", cc ); 113 setSize( w + 10, h + h1 + 10 ); 114 validate(); 115 } 116 } 117 118} 119