[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] MS-Mediaplayer don't work

I like to write a MediaPlayer-widget for WMP V9 acting like SWT.Browser. I'm always receiving an unexpected exception if I activate it with:

 site.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x4B64F839
Function=DllGetClassObject+0x2E8C4
Library=C:\WINNT\system32\wmp.dll


If I activate it with "OLEIVERB_SHOW" doesn't occur an exception but it doesn't show the video using all the frame space.

I'm new to SWT and OLE and I hope you can give me same help or is this an problem with MS-MediaPlayer?

Thanks Hanspeter

parts of the code:

public class MMediaPlayer extends Composite
{

  OleFrame frame;
  OleControlSite site;
  OleAutomation auto;

public MMediaPlayer(Composite parent, int style)
{
super(parent, style & ~SWT.BORDER);
frame = new OleFrame(this, SWT.NONE);
try
{
site = new OleControlSite(frame, SWT.NONE, "WMPlayer.OCX.7"); //$NON-NLS-1$
}
catch (SWTException e)
{
dispose();
SWT.error(SWT.ERROR_NO_HANDLES);
}
site.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
auto = new OleAutomation(site);
}


public String getStatus()
{
checkWidget();
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;
}


public boolean isRemote()
{
checkWidget();
int[] rgdispid = auto.getIDsOfNames(new String[]
{ "isRemote" }); //$NON-NLS-1$
Variant pVarResult = auto.getProperty(rgdispid[0]);
if (pVarResult == null || pVarResult.getType() != OLE.VT_BOOL) return false;
boolean result = pVarResult.getBoolean();
pVarResult.dispose();
return result;
}


  public boolean setUiMode(String mode)
  {
    checkWidget();
    if (mode == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
    int[] rgdispid = auto.getIDsOfNames(new String[]
    { "uiMode" }); //$NON-NLS-1$
    boolean result = auto.setProperty(rgdispid[0], new Variant(mode));
    return result;
  }

  public boolean setMpEnabled(boolean mode)
  {
    checkWidget();
    int[] rgdispid = auto.getIDsOfNames(new String[]
    { "enabled" }); //$NON-NLS-1$
    boolean result = auto.setProperty(rgdispid[0], new Variant(mode));
    return result;
  }

public boolean setStretchToFit(boolean mode)
{
checkWidget();
int[] rgdispid = auto.getIDsOfNames(new String[]{ "stretchToFit" }); //$NON-NLS-1$
boolean result = auto.setProperty(rgdispid[0], new Variant(mode));
return result;
}


  public boolean setAutoStart(boolean mode)
  {
    checkWidget();
    int[] rgdispid = auto.getIDsOfNames(new String[]
    { "settings" }); //$NON-NLS-1$
    Variant pVarResult = auto.getProperty(rgdispid[0]);
    if (pVarResult == null || pVarResult.getType() == 0) return false;
    OleAutomation settings = pVarResult.getAutomation();
    rgdispid = settings.getIDsOfNames(new String[]
    { "autoStart" }); //$NON-NLS-1$
    boolean result = settings.setProperty(rgdispid[0], new Variant(mode));
    settings.dispose();
    return result;
  }

  public boolean setWindowlessVideo(boolean mode)
  {
    checkWidget();
    int[] rgdispid = auto.getIDsOfNames(new String[]
    { "windowlessVideo" }); //$NON-NLS-1$
    boolean result = auto.setProperty(rgdispid[0], new Variant(mode));
    return result;
  }

  public boolean setFullScreen(boolean mode)
  {
    checkWidget();
    int[] rgdispid = auto.getIDsOfNames(new String[]
    { "fullScreen" }); //$NON-NLS-1$
    boolean result = auto.setProperty(rgdispid[0], new Variant(mode));
    return result;
  }

  public boolean setUrl(String url)
  {
    checkWidget();
    if (url == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
    int[] rgdispid = auto.getIDsOfNames(new String[]
    { "URL" }); //$NON-NLS-1$
    boolean result = auto.setProperty(rgdispid[0], new Variant(url));
    return result;
  }

  public void play()
  {
    checkWidget();
    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()
  {
    checkWidget();
    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();
  }

}