using the WindowMediaPlayer object on smartphone freezes application

C

Cristi Berneanu

Hello all,

I have made a .NET compact framework application for smartphone
devices which uses the WindowsMediaPlayer object to play a mp3 file.
Everything works fine until I call Application.Exit(). Then the
application won't exit completely and remains hanged, although in
TaskManager it doesn't show up anymore. This happens only when I use
the WindowsMediaPl;ayer object. Does anyone have any hints on what I
may be doing wrong?

Thanks in advance!
 
C

Cristi Berneanu

Steps to reproduce the problem:

1 - create a new Windows Mobile 5.0 Smartphone device application
2 - Add a reference to wmp.dll
3 - add this code anywhere:

WMPLib.WindowsMediaPlayer p = new
WMPLib.WindowsMediaPlayer();
p.URL = "\\Application Data\\Sounds\\Classic.wma";
p.controls.play();
System.Threading.Thread.Sleep(1000);
Application.Exit();

Could someone please confirm this so I know it isn't a problem on my
side?
 
N

Neil Cowburn

I can confirm this behavior. Even calling Marshal.ReleaseComObject() on the
WMP instance has no effect. Also, calling this.Close() instead of
Application.Exit() will close the form, but the application still does not
terminate.

--
Neil Cowburn
Principal Partner
OpenNETCF Consulting, LLC.

http://www.opennetcf.com/
 
C

Cristi Berneanu

Marshal.FinalReleaseComObject fixes the problem. Also all event
handlers must be removed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top