Been trying this for a while now. All solutions I've seen on the net don't seem to work, specially the really simple way to do it.
WMPLib.WindowsMediaPlayer c = new WMPLib.WindowsMediaPlayer();
IWMPMedia i = (IWMPMedia)c.currentMedia;
c.currentMedia is always null.
It seems that new WMPLib.WindowsMediaPlayer(); is always creating a new instance of the Windows Media Player. First I thought it was the fact that I was running visual studio as Administrator, but changing that did not help.
Seems I somehow have to connect to the running instance of wmplayer.exe but have unable to find a way to do that.
Btw. What I need is a full file url for the current playing song (or fullurl if streaming, but that's the least of my concerns now.)
Your question answered here.
A pretty straight way:
Get a WMP9 plugin here that will put your current song name on the titlebar of the WMP window, and use FindWindow P/Invoke to get the window and get the song name. It shoud work, though a little tricky.
Check here for more details.
A much more complex way:
Since your application and the WMP will be different processes, your scenario requires some kind of inter-process-communication (IPC). And .NET offers Remoting for this purpose.
Below are some useful information:
from SamAgain