SWT + JMF messy windows player

Source: Internet
Author: User

The biggest advantage of SWT is that Windows has a window style, which combines SWT with JMF, Windows external frame, and Java player. What do you think of me?


If you want to run my code, you must install jmf2.1.1e and import the swt jar file (remember to put the swt-win32-2135.dll in the execution path)


ImportJava. AWT. borderlayout;
ImportJava. AWT. component;
ImportJava. AWT. Panel;
ImportJava. Io. ioexception;
ImportJava.net. malformedurlexception;
ImportJava.net. url;

ImportJavax. Media. configurecompleteevent;
ImportJavax. Media. controllerevent;
ImportJavax. Media. controllerlistener;
ImportJavax. Media. endofmediaevent;
ImportJavax. Media. Manager;
ImportJavax. Media. noplayerexception;
ImportJavax. Media. player;
ImportJavax. Media. realizecompleteevent;

ImportOrg. Eclipse. jface. Window. window;
ImportOrg. Eclipse. SWT. SWT;
ImportOrg. Eclipse. SWT. Internal. AWT. win32.swt _ AWT;
ImportOrg. Eclipse. SWT. Widgets. display;
ImportOrg. Eclipse. SWT. Widgets. shell;

/**
* @ Author
* <A href = "mailto: jdcyang@yahoo.com.cn"> Liu Yang </a>
* 19:34:38
*/

Public ClassSwtplayerImplementsControllerlistener {

Public Static VoidMain (string [] ARGs ){
Swtplayer sp =NewSwtplayer ();
Sp. Play ();
}
Private BooleanConfigured =False;
Private BooleanRealized =False;
Player player;
Panel panel;
Public VoidPlay (){
Display display =NewDisplay ();
Shell shell =NewShell (display, SWT. MAX );
Shell. setSize (320,240 );
Shell. setText ("Hello SWT ");
Panel = SWT_AWT.New_ Panel (shell );
URL url = null;
Try{
Url =NewURL ("file:/D:/video/jboss. mpeg ");
}Catch(MalformedURLException e ){
E. printStackTrace ();
}
Try{
Player = Manager. createPlayer (url );
}Catch(NoPlayerException e1 ){
E1.printStackTrace ();
}Catch(IOException e1 ){
E1.printStackTrace ();
}

Player. addControllerListener (This);

Player. realize ();
While(! Realized ){
Try{
Thread. sleep (100L );;
}Catch(InterruptedException e ){
// Ignore
}
}
Panel. setLayout (NewBorderLayout ());
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. isdisposed ()){
If(! Display. readAndDispatch () display. sleep ();
}
Display. dispose ();
}
/* (Non-Javadoc)
* @ See javax. media. ControllerListener # controllerUpdate (javax. media. ControllerEvent)
*/

Public VoidControllerUpdate (ControllerEvent evt ){
If(EvtInstanceofRealizeCompleteEvent ){
Realized =True;
}ElseIf(EvtInstanceofConfigureCompleteEvent ){
Configured =True;
}Else If(EvtInstanceofEndOfMediaEvent ){
}Else{
}
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.