Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Embedded Windows Media Player (Read 5105 times)
rcruzmar
YaBB Newbies
*
Offline



Posts: 25
Location: FL
Joined: Sep 19th, 2007
Embedded Windows Media Player
Feb 11th, 2008 at 4:22pm
Print Post  
Hello,

Has anyone embedded the Windows Media Player within a box? What I need to know is how to set properties for this or any other OCX.

I already have been able to display the WMP within the box. but am not able to set and properties.

I am using VS2005 Pro "C++" and MFC.

Thanks!

Rolando
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Embedded Windows Media Player
Reply #1 - Feb 12th, 2008 at 6:21am
Print Post  
Hi,

Code
Select All
#import "wmp.dll" high_method_prefix("hi")

fcx.SetAxControlId(_T("WMPlayer.OCX"));

BoxItem box = fcx.CreateBox(0, 0, 300, 300);
box.SetStyle(bsAxControl);

WMPLib::IWMPPlayer4* player;
if (box.GetAxRawPtr() &&
	box.GetAxRawPtr()->QueryInterface(__uuidof(WMPLib::IWMPPlayer4), (void**)&player) == S_OK)
{
	player->put_URL(_bstr_t("file://D:/Video/HPIM0034.mpg"));
	player->Release();
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
rcruzmar
YaBB Newbies
*
Offline



Posts: 25
Location: FL
Joined: Sep 19th, 2007
Re: Embedded Windows Media Player
Reply #2 - Feb 12th, 2008 at 10:53am
Print Post  
Thanks for the reply. Your code did work after minor change to it. Here is the change:

fcx.SetAxControlId(_T("WMPlayer.OCX")); - rather than using "fcx." it should be "box."

At least that is what I had to do to get the code working! Grin

Now, the programming you present here is, I hate to admit Embarrassed is a little advanced for me. Based on what I read, am I to understand that this is a way to get a pointer to the Player object in order to work with it? I suppose I would write similar code in order to get other WMP object pointers so I can deal with Playlists and Media objects. Is this a correct assumption on my part? Roll Eyes

Also, I suppose would this be the way to embed a Flash object and have the contents playback?  Embarrassed

Thanks for the help.

Rolando
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Embedded Windows Media Player
Reply #3 - Feb 12th, 2008 at 11:11am
Print Post  
"fcx" above is my FlowChart object, so fcx.SetAxControlId sets the default ProgId that should be assigned to all new boxes. Of course you can set the property of individual boxes too.

Once you have the IWMPPlayer pointer, you can use its properties to access playlists and media. Check the IWMPCore documentation in the MSDN - that's the base interface of IWMPPlayer and it defines most of the useful properties and methods of the Media Player control.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
rcruzmar
YaBB Newbies
*
Offline



Posts: 25
Location: FL
Joined: Sep 19th, 2007
Re: Embedded Windows Media Player
Reply #4 - Feb 12th, 2008 at 12:06pm
Print Post  
I stand corrected. I did not realize this is what you were doing within your sample code.  Undecided

I suppose this is exactly what I would need to do in order to embed other object (Flash, Shackwave) into a box.

Rolando
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Embedded Windows Media Player
Reply #5 - Feb 12th, 2008 at 12:23pm
Print Post  
I guess so, as long as they are implemented as ActiveX controls.

Stoyan
  
Back to top
 
IP Logged
 
rcruzmar
YaBB Newbies
*
Offline



Posts: 25
Location: FL
Joined: Sep 19th, 2007
Re: Embedded Windows Media Player
Reply #6 - Feb 12th, 2008 at 1:13pm
Print Post  
I really can't figure this one out. I hope you can help. ???

I now have the Windows Media Player within a box and all works fine. The chart with the embedded player was loaded from a file.

Now, when I open another chart with another embedded WMP control the program crashes and I can't seem to locate the problem. All I know is that the program stack reports the problem originating within the ClearAll method. I've included the code below...

Here is the code - pretty straight foward stuff:
[code]
static char BASED_CODE szFilter[] = "VMLayEd Files (*.vml)|*.vml||";

// Create an Open dialog; the default file name extension is ".my".
CFileDialog fileDlg (TRUE, "vml", "untitled.vml",
OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, szFilter, this);

if (fileDlg.DoModal() == IDOK)
{
strFileName = fileDlg.GetPathName();
m_FlowCtrl.ClearAll();
m_FlowCtrl.LoadFromFile(strFileName);
m_btnSave.EnableWindow(FALSE);

GetDocument()->SetTitle(fileDlg.GetFileName());
GetDocument()->SetModifiedFlag(FALSE);
}[/code]

This was not discussed in the previous messages of this thread but, is there anything I need to do when clearing a chart that contains an embedded ActiveX control?

As always, thanks for your help.

Rolando
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Embedded Windows Media Player
Reply #7 - Feb 12th, 2008 at 1:34pm
Print Post  
The player instances might be in invalid state when FlowChartX sets their URL values while loading. Try stopping all players and setting their URL to an empty string before saving or calling ClearAll.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
rcruzmar
YaBB Newbies
*
Offline



Posts: 25
Location: FL
Joined: Sep 19th, 2007
Re: Embedded Windows Media Player
Reply #8 - Feb 12th, 2008 at 2:02pm
Print Post  
Alright, that fixed the problem.  Grin

Thanks so much for you assistance.

Rolando
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Embedded Windows Media Player
Reply #9 - Feb 12th, 2008 at 2:05pm
Print Post  
8)
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint