Archived

This topic is now archived and is closed to further replies.

Funkymunky

Windows Media Player

Recommended Posts

Hey, I''m trying to make a program for the LAN we have in my apartment here. We have one computer hooked up to some monster speakers which we use to play music at parties. We also have my computer with generic speakers and a laptop that sits in the living room. What I want to do is make a program that can control windows media player across the network. I think I can do the network programming pretty easily, but I can''t figure out how to mess with WMP. I downloaded the windows media series 9 SDK stuff, but can''t make any sense of how to use it. specifically, my call to CoCreateInstance to create the server object returns REGDB_E_CLASSNOTREG. Any help on using the SDK for simple stuff like playing/pausing/stopping a file and editing playlists? Could I maybe do it some other way, like with SendMessage calls or even command line options? Any help will be greatly appreciated by me and my roommates.

Share this post


Link to post
Share on other sites
I''d I''d I''d.. I''d just send commands over the network, and let the other side (the clientside) read those commands and work with WMP.

--
You''re Welcome,
Rick Wong

- sitting in his chair doing the most time-consuming thing..

Share this post


Link to post
Share on other sites

#!perl
# achtung: quick and messy server
use IO::Socket;

$PLAY = 0x1;
$STOP = 0x2;
# etc.

$server = IO::Socket::INET->new(LocalPort=> $server_port,
Type => SOCK_STREAM,
Reuse => 1,
Listen =>10)
or die "Sorry: $@\n";
while ($client = $server->accept()){
$server->recv($data_read, $maxlen, $flags) or die "Error.";
if($data_read == $PLAY){
system("wmplayer /Play myplaylist.wpl")
}
else if($data_read == $STOP) {
system("wmplayer /Stop");
}
else {
# more commands
}
}
   
#!perl
#achtung: messy messy client
use IO::Socket;

$PLAY = 0x1;
$STOP = 0x2;

$socket = IO::Socket::INET->new(PeerAddr => $remote_host, PeerPort => $remote_port,
Proto => 'tcp',
Type => SOCK_STREAM) or die "Error: $@\n";

print $socket "$PLAY";
print $socket "$STOP";
#...
close($socket);


[edited by - flangazor on April 5, 2004 1:15:27 PM]

[edited by - flangazor on April 6, 2004 7:18:38 AM]

Share this post


Link to post
Share on other sites
WMP is an ActiveX Control (Correct me if am wrong guys), so you can host it in your own app. Have another thread in the same app that listens to network calls and translate those calls to control the ActiveX Cntrl. One caveat is that you should always control the activex control from the UI thread. Using C# simplifies your prorgramming a lot. I think there may be some articles on codeproject.com with regard to using the WMP in a C# app. Good Luck.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Maybe the multimedia API...try searching for MCI Functions in ms sdk (pretty sure it plays video and audio).

You can also play with the winamp sdk, it is pretty easy to use.

Share this post


Link to post
Share on other sites
You can do it in VC++ too. Create a MFC Dialog App and import the ActiveX Control. MFC will generate wrapper classes (extends COleDispatchDriver I think) for your ActiveX Control and you could call the methods (like Play...) on these Wrapper Class to control your WMP. Check out Programming in Visual C++ book by Dave Kruglinski which has an example on how to import an Activex Control into a VC++ app. You still have to use Winsock on another thread to listen to connections and invoke the methods on the wrapper class.

Share this post


Link to post
Share on other sites
Also do you have to use WMP? Why not WinAmp? WinAmp comes with its own SDK and the last time I looked at it, it uses SendMessage calls to control it. I think the SDK had samples as to how you could use it and I remember someone providing a remote control interface to the player using SendMessage calls. It will simplify your task to a great extent. Just a thought.

Share this post


Link to post
Share on other sites
quote:
Damn, thanks for the help but I'm using visual studio 6, straight C++. Any more ideas?
Yes. I changed the above code to illustrate the command line arguments you can pass to wmplayer to control it. I haven't tested it, so I presume if it doesn't work, it's about 20 minutes from working and being done.

I guess you could read a few books, attempt to use MFC and OLE, and possibly even DDE to connect the apps at a data level. If you're bored and enjoy coding more than using programs.

[edited by - flangazor on April 6, 2004 7:27:14 AM]

Share this post


Link to post
Share on other sites
Or, a super easy way to get what you want without programming...

VNC

it will allow you to show the remote desktop, as if it was your own... so you could just control WMP directly...

Quick solution, over trying to program something..


------------------------------------------------------------
// TODO: Insert clever comment here.

Share this post


Link to post
Share on other sites