I am creating a sidebar program, that I would like to control an already open instance of Windows Media Player, is this possible through a Windows Media Player COM Component, I hope it is as I need the program to, if Windows Media Player isn't already open, start playing a playlist.
Normally no. Ususally it will just make a new instance of the mediaplayer.
To remotecontrol the regular mediaplayer you need a bit more tinkering.
Luckily I once found these interfaces that does just that.
Please don't ask me to support them, because I have no idea how they work.
I just translated them from C#, so I can't take any credit for anything.
Add them to the project, and add a reference the WMPLib.
Then you DIM myMP as New RemotedWindowsMediaPlayer and add it to your forms controlcollection.
Then it will be embeded like normal.
Then you can call myMP.Player.playerApplication.switchToPlayerApplication() to have the mediaplayer detach itself and run in it own regular window.
I use it myself, to make a server application on my pc, and a remote control on my PDA.
Works like a charm
I will give you the entire client/server apps if you like, but most of it is in danish. The relevant controlnames are in english so it should not be too hard to figure out.
Plus, I don't program that much, so the code could probably be optimized alot.
But it works, and thats enough for me
Anyways, (I'm just rambling on here, aren't I?) I have attached the interfaces.
Let me know if you're interrested in the complete apps.
Btw. the complete apps are in 2005.
Hope this helps you.
EDIT: Forgot to mention that if the mediaplayer is allready open, it just attaches itself to that, so it should be exactly what you need.
EDIT: Changed the line in red.
Last edited by pax; Feb 13th, 2006 at 02:23 PM.
I wish I could think of something witty to put in my sig...
Please excuse me for being an absolute dummy (Only started in VB2005 two days ago ) but:
1. WMPLib isn't there, but WMPProxyLib is
2. Do you have any actual code to make just this one object interact, without including extra forms??
EDIT: I run the application and when I click Change Type, get this error shortly after:
System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-1072885805
Message="Exception from HRESULT: 0xC00D0FD3"
Source="Interop.WMPLib"
Infact, for now, i'll just include a media player, hidden, and make my own UI through it's controls, only problem I had with doing this originally was that I couldnt find any way to make a playlist
Now I just have to make a playlist through the control buttons, and then find a way to show it in a listbox
It should all work well, and I'm sure I'll put your code to use in future versions I'll send you a link to the app. when i've finished it
EDIT: I run the application and when I click Change Type, get this error shortly after:
System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-1072885805
Message="Exception from HRESULT: 0xC00D0FD3"
Source="Interop.WMPLib"
I've had similiar problems when my app started.
I thought it was because my either form or the mediaplayer wasn't completly initialized when I switched the mode.
In my server app, I checked if the wmplayer process was running, and if it wasn't I would start it using Process.Start.
After that, I added the control to my panel and started to work with it.
And I had a few Application.DoEvents during this process.
This seems to have solved it.
If you just add the regular ActiveX you could be faced with the problem, that a users is listening to the "normal" mediaplayer, and then your's at the same time.
A Playlist,in it's simplest form, is just a textfile where each line is a path and filename of the mp3. called *.m3u
Anyway, glad I could of be some help. Hope you can use it sometime.
I wish I could think of something witty to put in my sig...