How to interact with Windows Media Player in C#

Just add a reference to wmp.dll (\windows\system32\wmp.dll)

using WMPLib;

And then you can instantiate a media player

var Player = new WindowsMediaPlayer();
// Load a playlist or file and then get the title 
var title = Player.controls.currentItem.name;

See Creating the Windows Media Player Control Programmatically for more information


For remoting the Windows Media Player, you can use the IWMPRemoteMediaServices interface to control the stand alone Windows Media Player. And you should be able to read all the informations you want like title or filename from your WMP player object. Unfortunately there is no C# smaple code in the SDK included. You can get the files from here: http://d.hatena.ne.jp/punidama/20080227 Look for the file WmpRemote.zip Originally it's from here: http://blogs.msdn.com/ericgu/archive/2005/06/22/431783.aspx

Then you have to cast to the WindowsMediaPlayer object: RemotedWindowsMediaPlayer rm = new RemotedWindowsMediaPlayer(); WMPLib.WindowsMediaPlayer myPlayer = this.GetOcx() as WMPLib.WindowsMediaPlayer;

and there you go..