Active2 years, 3 months ago
I am looking for a way to interact with a standalone full version of Windows Media Player.
Mostly I need to know the Path of the currently played track.
Mostly I need to know the Path of the currently played track.
The iTunes SDK makes this really easy but unfortunately there really isn't any way to do it with Windows Media Player, at least not in .Net(C#) without any heavy use of pinvoke, which I am not really comfortable with.
Thanks
Just to clearify: I don't want to embedded a new instance of Windows Media Player in my app, but instead control/read the 'real' full version of Windows Media Player, started seperatly by the user
- Windows Media Player cannot play the file. 1 If there are spaces in the name of your media files or the path of the files, you should remove them promptly. That may help. 2 If your media files are not in a Windows Media Player playlist, then go ahead and create it. To create a playlist, please fire up the Windows Media Player software.
- Windows media player can be launched from Run window by running the command wmplayer. This command does not work from command prompt as the environment variable ‘PATH‘ will not have media player binaries location path. You can directly launch the exe by specifying its location path in full.
- Windows Media Player, also known as WMP, is a media player and media library utility installed by default with Microsoft Windows operating system (Windows 8 excluded). It accepts a variety of video, audio files such as WMV, AVI, MPG, MP4 as input, as well as audio CDs, data CDs, and data DVDs.
eric
If you want to reinstall Windows Media Player, try the following: Click the Start button, type features, and select Turn Windows features on or off. Scroll down and expand Media Features, clear the Windows Media Player check box, and click OK. Restart your device. Windows Media Player should be uninstalled. Repeat step 1.
ericeric90155 gold badges1818 silver badges3131 bronze badges
4 Answers
I had this https://social.msdn.microsoft.com/Forums/vstudio/en-US/dbd43d7e-f3a6-4087-be06-df17e76b635d/windows-media-player-remoting-in-c?forum=clr in my bookmarks but have NOT tested it in anyway. Just a pointer in the right direction. It's nothing official and will require a bit of digging, but you should get a fairly simple wrapper (which will still use PInvoke under the hood - but you won't see it) around Windows Media Player.
Hope that helps.
Oh, I misunderstood. I thought you were talking about controlling the currently running Windows Media Player instance. If you are hosting Windows Media Player yourself then WMPLib is certainly the better solution.
Wodin![Windows Media Player Path Windows Media Player Path](/uploads/1/2/6/1/126139148/420431540.png)
2,29711 gold badge1717 silver badges3434 bronze badges
Alex DugglebyAlex Duggleby6,33355 gold badges3434 silver badges4343 bronze badges
Just add a reference to wmp.dll (windowssystem32wmp.dll)
And then you can instantiate a media player
See Creating the Windows Media Player Control Programmatically for more information
Markus OlssonMarkus Olsson20.3k88 gold badges4949 silver badges6060 bronze badges
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.zipOriginally 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..
zzht
The best info I have seen on interacting with Windows Media Player is this article written by Stephen Toub.
He lists a whole load of different ways to play dvr-ms files (doesn't really matter what format they are for this though). The bit that is possibly of interest to you is about using a Media Player ActiveX Control, which you can add to the visual Studio toolbox by right-clicking and adding the Windows Media Player ActiveX COM Control. You can then embed the player into your app, and access various properties of Media Player, like the url:
This solution is possibly not what you want because it's starting a new instance of Media Player (as far as I know), however it might point you in the right direction.
Dave ArkellDave Arkell3,09422 gold badges1818 silver badges2626 bronze badges