X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.editors.win32%2Fsrc%2Forg%2Fsimantics%2Feditors%2Fwin32%2Fole%2FWMPController.java;h=02b1fbf84606722590ec9e4e07666297b0e64107;hb=c514d4d064547c6bd0bf2b7c182e5f8c7e389c6c;hp=a597a91bedff49612d2a4a2d86232ea0ba9ed768;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.editors.win32/src/org/simantics/editors/win32/ole/WMPController.java b/bundles/org.simantics.editors.win32/src/org/simantics/editors/win32/ole/WMPController.java index a597a91be..02b1fbf84 100644 --- a/bundles/org.simantics.editors.win32/src/org/simantics/editors/win32/ole/WMPController.java +++ b/bundles/org.simantics.editors.win32/src/org/simantics/editors/win32/ole/WMPController.java @@ -1,132 +1,132 @@ -/******************************************************************************* - * 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; - } - -} +/******************************************************************************* + * 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; + } + +}