1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.editors.win32.ole;
14 import org.eclipse.swt.ole.win32.OLE;
15 import org.eclipse.swt.ole.win32.OleAutomation;
16 import org.eclipse.swt.ole.win32.OleClientSite;
17 import org.eclipse.swt.ole.win32.OleFrame;
18 import org.eclipse.swt.ole.win32.Variant;
19 import org.simantics.editors.win32.OLEEditorInput;
23 * Windows Media Player utility.
25 * Note: there is a bug with WMP11: it launches WMP website when the control is activated.
27 * @see http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg20193.html
32 public class WMPController implements OleController {
38 public WMPController(OleFrame frame, OleClientSite site, OleAutomation auto) {
44 public void show(OLEEditorInput input) {
45 site.doVerb(OLE.OLEIVERB_SHOW);
46 // size must be 240x245 and uiMode full to correctly align the player component with the editor
47 frame.setSize(240, 245);
48 // WMP11 won't show video, if uimode is not set to none when URL is set
52 String url = "file:///"+ input.getFile().getAbsoluteFile();
53 url = url.replace('\\', '/');
54 System.out.println(url);
58 // URL has been set, so we can set uimode to full
62 public void setUIMode(String mode) {
63 int ids[] = auto.getIDsOfNames(new String[] { "uiMode" });
65 auto.setProperty(ids[0], new Variant(mode)); //"none","full"
69 public void setStrechToFit(boolean fit) {
70 int ids[] = auto.getIDsOfNames(new String[] { "stretchToFit" });
72 auto.setProperty(ids[0], new Variant(fit));
76 public void loadMedia(String url) {
78 rgdispid = auto.getIDsOfNames(new String[]{"URL"});
79 if (rgdispid != null) {
80 int dispIdMember = rgdispid[0];
82 boolean b = auto.setProperty(dispIdMember, new Variant(url));
83 System.out.println(b);
88 int[] rgdispid = auto.getIDsOfNames(new String[] { "controls" }); //$NON-NLS-1$
89 Variant pVarResult = auto.getProperty(rgdispid[0]);
90 if (pVarResult == null || pVarResult.getType() == 0)
92 OleAutomation controls = pVarResult.getAutomation();
93 rgdispid = controls.getIDsOfNames(new String[] { "play" }); //$NON-NLS-1$
94 controls.invoke(rgdispid[0]);
100 int[] rgdispid = auto.getIDsOfNames(new String[] { "controls" }); //$NON-NLS-1$
101 Variant pVarResult = auto.getProperty(rgdispid[0]);
102 if (pVarResult == null || pVarResult.getType() == 0) return;
103 OleAutomation controls = pVarResult.getAutomation();
104 rgdispid = controls.getIDsOfNames(new String[]{ "stop" }); //$NON-NLS-1$
105 controls.invoke(rgdispid[0]);
106 pVarResult.dispose();
110 public boolean setFullScreen(boolean mode) {
111 int[] rgdispid = auto.getIDsOfNames(new String[] { "fullScreen" }); //$NON-NLS-1$
112 boolean result = auto.setProperty(rgdispid[0], new Variant(mode));
116 public boolean setWindowlessVideo(boolean mode) {
117 int[] rgdispid = auto.getIDsOfNames(new String[] { "windowlessVideo" }); //$NON-NLS-1$
118 boolean result = auto.setProperty(rgdispid[0], new Variant(mode));
122 public String getStatus() {
123 int[] rgdispid = auto.getIDsOfNames(new String[] { "status" }); //$NON-NLS-1$
124 Variant pVarResult = auto.getProperty(rgdispid[0]);
125 if (pVarResult == null || pVarResult.getType() != OLE.VT_BSTR)
127 String result = pVarResult.getString();
128 pVarResult.dispose();