swtplayer

来源:互联网 发布:手机淘宝找同款在哪里 编辑:程序博客网 时间:2024/05/01 20:40

package de.tutorials;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.ole.win32.OleAutomation;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.ole.win32.Variant;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class SWTVideoPlayer {

 public static void main(String[] args) {
  Display display = new Display();
  Shell shell = new Shell(display);

  shell.setText("SWT Video Player");

  shell.setSize(640, 480);

  shell.setLayout(new FillLayout());

  OleFrame frm = new OleFrame(shell, SWT.NONE);

  OleClientSite site = new OleClientSite(frm, SWT.NONE,
    "MediaPlayer.MediaPlayer.1");
  OleAutomation auto = new OleAutomation(site);
  int[] ids = null;
  ids = auto.getIDsOfNames(new String[] { "Open" });
  auto.invoke(ids[0],
    new Variant[] { new Variant("C://WINNT//clock.avi") });

  ids = auto.getIDsOfNames(new String[] { "Play" });
  auto.invoke(ids[0]);

  shell.open();

  while (!shell.isDisposed())
   if (!display.readAndDispatch())
    display.sleep();

  site.deactivateInPlaceClient();

  site.dispose();
  auto.dispose();
 }

原创粉丝点击