Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » WMPlayer.OCX (Windows Media Player) trouble
WMPlayer.OCX (Windows Media Player) trouble [message #456737] Wed, 08 June 2005 09:01 Go to next message
Philip Mayer is currently offline Philip MayerFriend
Messages: 1
Registered: July 2009
Junior Member
Hello everyone,

This has been in this group before, but I didn't really find a solution
for it. The problem is as follows:

I am trying to use the Windows Media Player (v.10), WMPlayer.OCX, to
display video inside an SWT frame. I have sucessfully activated the
control and played back some video (Eclipse3.1RC1).

The control, however, cannot be activated using
OLE.OLEIVERB_INPLACEACTIVATE (results in a VM crash; there is a bug
report on this), but only using OLE.OLEIVERB_SHOW. I SUSPECT that all
the following problems are because of this (correct?).

So, when using OLEIVERB_SHOW, it is VERY difficult to set the sizes of
the OleFrame and the OleControlSite to the right values in order to
display the whole video picture (and only the picture) inside the frame.
There are really weird things going on there; mostly, the video is
displayed only partly and in strange places inside the black media
player area (right click to invoke the media player context menu is
possible everwhere). I have found the size (300/206) to be working for
me - but only this size, which really is not a solution.

If I use FillLayout or any other layout which allows me to resize the
control, the video gets only partly displayed. I tried setting the
control's size via listeners, but this doesn't work.

Attached is some code which shows how the WMPlayer tries to play back
the video somewhere inside the frame.

Any ideas? :) Thanks !! :)

-phil

---
public class Snippet3
{
private OleAutomation player;

public Snippet3()
{
final Display display = new Display();
Shell shell = new Shell(display);
Composite c1 = new Composite(shell,SWT.NONE);
shell.setLayout(new FillLayout());
c1.setLayout(new FillLayout());
OleControlSite controlSite;

try
{
OleFrame frame = new OleFrame(c1,SWT.NONE);
controlSite = new
OleControlSite(frame,SWT.NONE,"WMPlayer.OCX");
controlSite.doVerb(OLE.OLEIVERB_SHOW);
}
catch (SWTError e)
{
System.out.println("Unable to open activeX control");
return;
}
player = new OleAutomation(controlSite);

c1.setFocus(); // prevents vm from crashing on shutdown.

shell.pack();
shell.open();

setUIMode("none"); // does not display anything without this line.
loadFile("c:/windows/clock.avi");

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

player.dispose();
display.dispose();
}

public boolean loadFile(String URL) {
int[] ids = player.getIDsOfNames(new String[] { "URL" });
if (ids != null) {
Variant theFile = new Variant(URL);
return player.setProperty(ids[0], theFile);
}
return false;
}

private void setUIMode(String s) {
int ids[] = player.getIDsOfNames(new String[] { "uiMode" });
if (ids != null) {
player.setProperty(ids[0], new Variant(s));
}
}

public static void main(String[] args) {
new Snippet3();
}
}
---
Re: WMPlayer.OCX (Windows Media Player) trouble [message #457884 is a reply to message #456737] Wed, 06 July 2005 13:34 Go to previous message
Eclipse UserFriend
Originally posted by: ""jantb\".(SPAM).ifi.uio.no"

Hello Ive gotten this to work with a little workaround. You need to set
the size of the OleFrame to the media players default size,240x245, with
UImode set too full, and the do a .layout() on the parent of OleFrame.
This will make the media player fit correctly in the window.

Philip Mayer wrote:
> Hello everyone,
>
> This has been in this group before, but I didn't really find a solution
> for it. The problem is as follows:
>
> I am trying to use the Windows Media Player (v.10), WMPlayer.OCX, to
> display video inside an SWT frame. I have sucessfully activated the
> control and played back some video (Eclipse3.1RC1).
>
> The control, however, cannot be activated using
> OLE.OLEIVERB_INPLACEACTIVATE (results in a VM crash; there is a bug
> report on this), but only using OLE.OLEIVERB_SHOW. I SUSPECT that all
> the following problems are because of this (correct?).
>
> So, when using OLEIVERB_SHOW, it is VERY difficult to set the sizes of
> the OleFrame and the OleControlSite to the right values in order to
> display the whole video picture (and only the picture) inside the frame.
> There are really weird things going on there; mostly, the video is
> displayed only partly and in strange places inside the black media
> player area (right click to invoke the media player context menu is
> possible everwhere). I have found the size (300/206) to be working for
> me - but only this size, which really is not a solution.
>
> If I use FillLayout or any other layout which allows me to resize the
> control, the video gets only partly displayed. I tried setting the
> control's size via listeners, but this doesn't work.
>
> Attached is some code which shows how the WMPlayer tries to play back
> the video somewhere inside the frame.
>
> Any ideas? :) Thanks !! :)
>
> -phil
>
> ---
> public class Snippet3
> {
> private OleAutomation player;
>
> public Snippet3()
> {
> final Display display = new Display();
> Shell shell = new Shell(display);
> Composite c1 = new Composite(shell,SWT.NONE);
> shell.setLayout(new FillLayout());
> c1.setLayout(new FillLayout());
> OleControlSite controlSite;
>
> try
> {
> OleFrame frame = new OleFrame(c1,SWT.NONE);
> controlSite = new
> OleControlSite(frame,SWT.NONE,"WMPlayer.OCX");
> controlSite.doVerb(OLE.OLEIVERB_SHOW);
> }
> catch (SWTError e)
> {
> System.out.println("Unable to open activeX control");
> return;
> }
> player = new OleAutomation(controlSite);
>
> c1.setFocus(); // prevents vm from crashing on shutdown.
>
> shell.pack();
> shell.open();
>
> setUIMode("none"); // does not display anything without this line.
> loadFile("c:/windows/clock.avi");
>
> while ( !shell.isDisposed())
> {
> if ( !display.readAndDispatch())
> display.sleep();
> }
>
> player.dispose();
> display.dispose();
> }
>
> public boolean loadFile(String URL) {
> int[] ids = player.getIDsOfNames(new String[] { "URL" });
> if (ids != null) {
> Variant theFile = new Variant(URL);
> return player.setProperty(ids[0], theFile);
> }
> return false;
> }
>
> private void setUIMode(String s) {
> int ids[] = player.getIDsOfNames(new String[] { "uiMode" });
> if (ids != null) {
> player.setProperty(ids[0], new Variant(s));
> }
> }
>
> public static void main(String[] args) {
> new Snippet3();
> }
> }
> ---
Previous Topic:How do I set the height of a table row?
Next Topic:Using Forms to view and edit properties
Goto Forum:
  


Current Time: Wed Sep 25 12:52:56 GMT 2024

Powered by FUDForum. Page generated in 0.03380 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top