Books for developers


Discuss in
the forum


A Windows Media Player plug-in

Here's the code to accompany the Hands On feature in the July 2004 issue. It is a Visual C++ 2003 project. When loaded into Media Player 9.0, it writes out the "Now Playing" information to a text file. You can then use this file as input for such things as an LCD panel or an email signature.

I've included a release build of the DLL in the download (in the Release folder), so that non-programmers can also make use of it if they wish.

Download the code.

Registering the dll

If you downloaded the binary, you will need to register it before it appears as a plug-in. To do so, run the following from a command prompt or the Start - Run dialog:

regsvr32 HandsOnWMP.dll

You will need the full path to the dll if you run this outside the directory where the dll is located. You can unregister it like this:

regsvr32 /u HandsOnWMP.dll

Improving the code

There's a small problem with the code as it stands. When you play a CD for the first time, Windows Media Player goes off to download the title and artist details, assuming you are connected to the Internet. However, the PlayStateChange event, used by the plug-in to trigger writing out the file, fires for the wmppsPlaying state before the title/artist information has been downloaded. There doesn't seem to be an event fired after the download of the info.

What this means is that the plug-in writes out "unknown title" or whatever when you play a CD for the first time. The information is cached, so it is fine next time the CD is played, and WMA or MP3 files are not affected as the data is already in the file.

I'm wondering about using a timer to re-generate the file a couple of times if it fails to find the information. Or maybe someone has a better idea - if so, email me or post a comment in the forum. I'll make sure any revised code is posted here.





Your comments



Copyright Tim Anderson 15th May 2004. All rights reserved.

New RSS feed - monitor this site with XML


Comments are closed.