Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
media
danimation.controls
danimation.programming
devices
drm
dshow.programming
dtransform
encoder
encoder.optimization
hometheaterpc
media
media.beta
media.beta.encoder
mediacenter
mediacenter.portable
mediaplayer
music.products
musicproducer
player
player.plugins
player.skins
player.solaris
player.visualizations
player.web
sdk
server
tools
  
 
date: Fri, 3 Jul 2009 22:20:01 -0700,    group: microsoft.public.windowsmedia.sdk        back       


Closing Windows Media Player when Remoted   
Hi,
Im using a remoted instance of windows media player, using a background 
worker thread to read information from windows media player. However, once i 
close windows media player, the background process (wmplayer) remains open, 
since my background worker is still connected. The background worker connects 
when it detects wmplayer.exe opens, i.e. it checks whether the process is 
running. The code is use to connect is as below (in c#)

using WMPLib;

Object COMPlayer;
Type WMP = Type.GetTypeFromCLSID(new 
Guid("6bf52a52-394a-11d3-b153-00c04f79faa6"));
COMPlayer = Activator.CreateInstance(WMP);
IOleObject IOO = COMPlayer as IOleObject;
IOO.SetClientSite(this as IOleClientSite);
remotedPlayer = COMPlayer as WindowsMediaPlayer;
private WindowsMediaPlayer remotedPlayer;

Is there a way to allow Windows Media Player to terminate once I close the 
main window?

Thanks
date: Fri, 3 Jul 2009 22:20:01 -0700   author:   SPauka

Re: Closing Windows Media Player when Remoted   
From: "SPauka"

> Im using a remoted instance of windows media player,
> using a background worker thread to read information from
> windows media player. However, once i close windows media
> player, the background process (wmplayer) remains open,
> since my background worker is still connected. The
> background worker connects when it detects wmplayer.exe
> opens, i.e. it checks whether the process is running. The
> code is use to connect is as below (in c#)

WMP terminates when the COM object is fully released. In 
.NET's COM InterOp, this naturally happens when the object 
is garbage-collected, which requires all of the outstanding 
references to go out of scope and some time to pass until 
the GC decides to act. If you want yo immediately release 
the COM object, invoke 
System.Runtime.InteropServices.FinalReleaseComObject().




-- 
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
date: Sat, 4 Jul 2009 11:44:16 +0200   author:   Alessandro Angeli

Re: Closing Windows Media Player when Remoted   
The issue is not releasing the object, rather it is that currently i have no 
way of knowing when I should close the remoted session. Hence, i do not know 
when to release the object. Is there an event that occurs when the main 
window closes?
Thanks

"Alessandro Angeli" wrote:

> From: "SPauka"
> 
> > Im using a remoted instance of windows media player,
> > using a background worker thread to read information from
> > windows media player. However, once i close windows media
> > player, the background process (wmplayer) remains open,
> > since my background worker is still connected. The
> > background worker connects when it detects wmplayer.exe
> > opens, i.e. it checks whether the process is running. The
> > code is use to connect is as below (in c#)
> 
> WMP terminates when the COM object is fully released. In 
> ..NET's COM InterOp, this naturally happens when the object 
> is garbage-collected, which requires all of the outstanding 
> references to go out of scope and some time to pass until 
> the GC decides to act. If you want yo immediately release 
> the COM object, invoke 
> System.Runtime.InteropServices.FinalReleaseComObject().
> 
> 
> 
> 
> -- 
> // Alessandro Angeli
> // MVP :: DirectShow / MediaFoundation
> // mvpnews at riseoftheants dot com
> // http://www.riseoftheants.com/mmx/faq.htm 
> 
> 
>
date: Sat, 4 Jul 2009 05:18:01 -0700   author:   SPauka

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us