[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.platform.swt] WMPlayer.OCX (Windows Media Player) trouble
|
- From: Philip Mayer <news@xxxxxxxxxx>
- Date: Wed, 08 Jun 2005 11:01:49 +0200
- Newsgroups: eclipse.platform.swt
- Organization: EclipseCorner
- User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
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();
}
}
---