The biggest advantage of SWT JMF Windows player SWT is that Windows has a window style, combined with SWT and JMF, Windows, Java's player, how do you think I think? If you want to run my code, you have to install JMF2.1.1e and import the SWT JAR file (remember to put SWT-Win32-2135.dll under the execution path).
import java.awt.BorderLayout; import java.awt.Component; import java.awt.Panel; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import javax.media.ConfigureCompleteEvent; import javax.media.ControllerEvent; import javax.media.ControllerListener; import javax.media.EndOfMediaEvent; import javax.media.Manager; import javax.media.NoPlayerException; import javax.media.Player; import javax.media.RealizeCompleteEvent; import org .eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.internal.awt.win32.SWT_AWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt .widgets.Shell; / ** * @Author * Liu Yang * 2003-7-17 19:34:38 * / public class swtplayer imports ControllerListener {public static void main (String [] args) {SWTPlayer sp = new SWTPlayer (); sp.play ();} private boolean configured = false; private boolean realized = false; Player player; Panel panel; public v Oid Play () {DISPLAY DISPLAY = New Display (); Shell Shell = New Shell (Display, Swt.max); Shell.setsize (320, 240); Shell.Settext ("Hello SWT"); Panel = SWT_AWT.NEW_PANEL ( Shell); URL URL = NULL; Try {URL = New URL ("File: / D: /Video/jboss.mpeg");} catch (mALFORMEDURLEXCEPTION E) {E.PrintStackTrace ();} try {player = manager. CREATEPLAYER (URL);} catch (NOPLAYEREXCEPTION E1) {E1.PrintStackTrace ();} catch (ooexception e1) {e1.printstacktrace ();} Player.addControllerListener (this);
Player.Realize (); while {thread.sleep (100L) ;;}} catch (interruptedException e) {// ignore}} Panel.setLayout (New borderLayout ()); panel.add (Player. GetVisualcomponent (), borderlayout.center; Component CPC = Player.getControlPanelcomponent (); if (cpc! = null) {Panel.Add (CPC, BorderLayout.South);} else {} Player.Start (); shell.Open (); Window Win; While (! Shell.iedisposed ()) {if (! Display.readddispatch ()) display.sleep ();} display.dispose ();} / * (non-javadoc) * @see javax .media.ControllerListener # controllerUpdate (javax.media.ControllerEvent) * / public void controllerUpdate (ControllerEvent evt) {if (evt instanceof RealizeCompleteEvent) {realized = true;} else if (evt instanceof ConfigureCompleteEv ELSE IF (EVT InstanceOf EndofmediaEvent) {} else {}}}}}}}}}}}: Java Original Community Zergling Original Date: 2004-10-26