]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.editors.win32/src/org/simantics/editors/win32/ole/WMPController.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.editors.win32 / src / org / simantics / editors / win32 / ole / WMPController.java
index a597a91bedff49612d2a4a2d86232ea0ba9ed768..02b1fbf84606722590ec9e4e07666297b0e64107 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.editors.win32.ole;\r
-\r
-import org.eclipse.swt.ole.win32.OLE;\r
-import org.eclipse.swt.ole.win32.OleAutomation;\r
-import org.eclipse.swt.ole.win32.OleClientSite;\r
-import org.eclipse.swt.ole.win32.OleFrame;\r
-import org.eclipse.swt.ole.win32.Variant;\r
-import org.simantics.editors.win32.OLEEditorInput;\r
-\r
-\r
-/**\r
- * Windows Media Player utility.\r
- * \r
- * Note: there is a bug with WMP11: it launches WMP website when the control is activated.\r
- * \r
- * @see http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg20193.html\r
- * \r
- * @author MLMARKO\r
- *\r
- */\r
-public class WMPController implements OleController {\r
-       \r
-       OleFrame frame;\r
-       OleClientSite site;\r
-       OleAutomation auto;\r
-       \r
-       public WMPController(OleFrame frame, OleClientSite site, OleAutomation auto) {\r
-               this.frame = frame;\r
-               this.site = site;\r
-               this.auto = auto;\r
-       }\r
-       \r
-       public void show(OLEEditorInput input) {\r
-               site.doVerb(OLE.OLEIVERB_SHOW);\r
-               // size must be 240x245 and uiMode full to correctly align the player component with the editor\r
-               frame.setSize(240, 245);\r
-               // WMP11 won't show video, if uimode is not set to none when URL is set\r
-               setUIMode("none");\r
-        setStrechToFit(true);\r
-        \r
-        String url = "file:///"+ input.getFile().getAbsoluteFile();\r
-               url = url.replace('\\', '/');\r
-               System.out.println(url);\r
-               loadMedia(url);\r
-        \r
-               frame.layout();\r
-               // URL has been set, so we can set uimode to full\r
-               setUIMode("full");\r
-       }\r
-       \r
-       public void setUIMode(String mode) {\r
-               int ids[] = auto.getIDsOfNames(new String[] { "uiMode" });\r
-        if (ids != null) {\r
-            auto.setProperty(ids[0], new Variant(mode)); //"none","full"\r
-        }\r
-       }\r
-       \r
-       public void setStrechToFit(boolean fit) {\r
-               int ids[] = auto.getIDsOfNames(new String[] { "stretchToFit" });\r
-        if (ids != null) {\r
-            auto.setProperty(ids[0], new Variant(fit));\r
-        }\r
-       }\r
-       \r
-       public void loadMedia(String url) {\r
-               int[] rgdispid;\r
-               rgdispid = auto.getIDsOfNames(new String[]{"URL"});\r
-               if (rgdispid != null) {\r
-                       int dispIdMember = rgdispid[0];\r
-                       \r
-                       boolean b = auto.setProperty(dispIdMember, new Variant(url));\r
-                       System.out.println(b);\r
-               }       \r
-       }\r
-       \r
-       public void play() {\r
-               int[] rgdispid = auto.getIDsOfNames(new String[] { "controls" }); //$NON-NLS-1$\r
-               Variant pVarResult = auto.getProperty(rgdispid[0]);\r
-               if (pVarResult == null || pVarResult.getType() == 0)\r
-                       return;\r
-               OleAutomation controls = pVarResult.getAutomation();\r
-               rgdispid = controls.getIDsOfNames(new String[] { "play" }); //$NON-NLS-1$\r
-               controls.invoke(rgdispid[0]);\r
-               pVarResult.dispose();\r
-               controls.dispose();\r
-       }\r
-       \r
-       public void stop() {\r
-               int[] rgdispid = auto.getIDsOfNames(new String[] { "controls" }); //$NON-NLS-1$\r
-               Variant pVarResult = auto.getProperty(rgdispid[0]);\r
-               if (pVarResult == null || pVarResult.getType() == 0) return;\r
-               OleAutomation controls = pVarResult.getAutomation();\r
-               rgdispid = controls.getIDsOfNames(new String[]{ "stop" }); //$NON-NLS-1$\r
-               controls.invoke(rgdispid[0]);\r
-               pVarResult.dispose();\r
-               controls.dispose();\r
-    }\r
-       \r
-       public boolean setFullScreen(boolean mode) {\r
-               int[] rgdispid = auto.getIDsOfNames(new String[] { "fullScreen" }); //$NON-NLS-1$\r
-               boolean result = auto.setProperty(rgdispid[0], new Variant(mode));\r
-               return result;\r
-       }\r
-       \r
-       public boolean setWindowlessVideo(boolean mode) {\r
-               int[] rgdispid = auto.getIDsOfNames(new String[] { "windowlessVideo" }); //$NON-NLS-1$\r
-               boolean result = auto.setProperty(rgdispid[0], new Variant(mode));\r
-               return result;\r
-       }\r
-       \r
-       public String getStatus() {\r
-               int[] rgdispid = auto.getIDsOfNames(new String[] { "status" }); //$NON-NLS-1$\r
-               Variant pVarResult = auto.getProperty(rgdispid[0]);\r
-               if (pVarResult == null || pVarResult.getType() != OLE.VT_BSTR)\r
-                       return "";\r
-               String result = pVarResult.getString();\r
-               pVarResult.dispose();\r
-               return result;\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.editors.win32.ole;
+
+import org.eclipse.swt.ole.win32.OLE;
+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.simantics.editors.win32.OLEEditorInput;
+
+
+/**
+ * Windows Media Player utility.
+ * 
+ * Note: there is a bug with WMP11: it launches WMP website when the control is activated.
+ * 
+ * @see http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg20193.html
+ * 
+ * @author MLMARKO
+ *
+ */
+public class WMPController implements OleController {
+       
+       OleFrame frame;
+       OleClientSite site;
+       OleAutomation auto;
+       
+       public WMPController(OleFrame frame, OleClientSite site, OleAutomation auto) {
+               this.frame = frame;
+               this.site = site;
+               this.auto = auto;
+       }
+       
+       public void show(OLEEditorInput input) {
+               site.doVerb(OLE.OLEIVERB_SHOW);
+               // size must be 240x245 and uiMode full to correctly align the player component with the editor
+               frame.setSize(240, 245);
+               // WMP11 won't show video, if uimode is not set to none when URL is set
+               setUIMode("none");
+        setStrechToFit(true);
+        
+        String url = "file:///"+ input.getFile().getAbsoluteFile();
+               url = url.replace('\\', '/');
+               System.out.println(url);
+               loadMedia(url);
+        
+               frame.layout();
+               // URL has been set, so we can set uimode to full
+               setUIMode("full");
+       }
+       
+       public void setUIMode(String mode) {
+               int ids[] = auto.getIDsOfNames(new String[] { "uiMode" });
+        if (ids != null) {
+            auto.setProperty(ids[0], new Variant(mode)); //"none","full"
+        }
+       }
+       
+       public void setStrechToFit(boolean fit) {
+               int ids[] = auto.getIDsOfNames(new String[] { "stretchToFit" });
+        if (ids != null) {
+            auto.setProperty(ids[0], new Variant(fit));
+        }
+       }
+       
+       public void loadMedia(String url) {
+               int[] rgdispid;
+               rgdispid = auto.getIDsOfNames(new String[]{"URL"});
+               if (rgdispid != null) {
+                       int dispIdMember = rgdispid[0];
+                       
+                       boolean b = auto.setProperty(dispIdMember, new Variant(url));
+                       System.out.println(b);
+               }       
+       }
+       
+       public void play() {
+               int[] rgdispid = auto.getIDsOfNames(new String[] { "controls" }); //$NON-NLS-1$
+               Variant pVarResult = auto.getProperty(rgdispid[0]);
+               if (pVarResult == null || pVarResult.getType() == 0)
+                       return;
+               OleAutomation controls = pVarResult.getAutomation();
+               rgdispid = controls.getIDsOfNames(new String[] { "play" }); //$NON-NLS-1$
+               controls.invoke(rgdispid[0]);
+               pVarResult.dispose();
+               controls.dispose();
+       }
+       
+       public void stop() {
+               int[] rgdispid = auto.getIDsOfNames(new String[] { "controls" }); //$NON-NLS-1$
+               Variant pVarResult = auto.getProperty(rgdispid[0]);
+               if (pVarResult == null || pVarResult.getType() == 0) return;
+               OleAutomation controls = pVarResult.getAutomation();
+               rgdispid = controls.getIDsOfNames(new String[]{ "stop" }); //$NON-NLS-1$
+               controls.invoke(rgdispid[0]);
+               pVarResult.dispose();
+               controls.dispose();
+    }
+       
+       public boolean setFullScreen(boolean mode) {
+               int[] rgdispid = auto.getIDsOfNames(new String[] { "fullScreen" }); //$NON-NLS-1$
+               boolean result = auto.setProperty(rgdispid[0], new Variant(mode));
+               return result;
+       }
+       
+       public boolean setWindowlessVideo(boolean mode) {
+               int[] rgdispid = auto.getIDsOfNames(new String[] { "windowlessVideo" }); //$NON-NLS-1$
+               boolean result = auto.setProperty(rgdispid[0], new Variant(mode));
+               return result;
+       }
+       
+       public String getStatus() {
+               int[] rgdispid = auto.getIDsOfNames(new String[] { "status" }); //$NON-NLS-1$
+               Variant pVarResult = auto.getProperty(rgdispid[0]);
+               if (pVarResult == null || pVarResult.getType() != OLE.VT_BSTR)
+                       return "";
+               String result = pVarResult.getString();
+               pVarResult.dispose();
+               return result;
+       }
+
+}