billou2k
8th February 2005, 19:22
I've started playing with MPC's webserver and it gave me the idea of doing some quality comparison tests with friends.
The idea is to put DivX files on one PC and XviD files on the other one PC next to it. (I guess it's easier to compare when you can see both clips at the same time rather than watching them the ones after the others.)
So from a laptop (on the same LAN) I'd like to send the command to start/pause the divx/xvid clips to the two MPC's webservers, so that it is sort of synchronised...
I have no particular preference on how to do this..
I've found that perl was quite convenient to send HTTP requests (I've never done any web/network coding before). I've managed to connect with perl to MPC's webserver (got the html code back) unfortunately I'm not sure what content to send to simulate the POST request to start / pause the players (looking at the HTML source I know that I should send something like "wm_command=155" to start playing and "156" to pause... but I'm not sure of how to send it and I dont know if I need to handle cookies, sessionIDs etc..
Here is what I've been trying for the moment, it doesn't crash but it doesnt have any effect on MPC yet :)
# Create a user agent object
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
# Create a request
$req->content_type('application/x-www-form-urlencoded');
$req->content('wm_command=156');
# Pass request to the user agent and get a response back
my $res = $ua->request($req);
# Check the outcome of the response
if ($res->is_success) {
print $res->content;
}
else {
print $res->status_line, "\n";
}
Well anyway if you have any idea on how to do that in perl or in any other way, I'll be glad to hear from you:D
The idea is to put DivX files on one PC and XviD files on the other one PC next to it. (I guess it's easier to compare when you can see both clips at the same time rather than watching them the ones after the others.)
So from a laptop (on the same LAN) I'd like to send the command to start/pause the divx/xvid clips to the two MPC's webservers, so that it is sort of synchronised...
I have no particular preference on how to do this..
I've found that perl was quite convenient to send HTTP requests (I've never done any web/network coding before). I've managed to connect with perl to MPC's webserver (got the html code back) unfortunately I'm not sure what content to send to simulate the POST request to start / pause the players (looking at the HTML source I know that I should send something like "wm_command=155" to start playing and "156" to pause... but I'm not sure of how to send it and I dont know if I need to handle cookies, sessionIDs etc..
Here is what I've been trying for the moment, it doesn't crash but it doesnt have any effect on MPC yet :)
# Create a user agent object
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
# Create a request
$req->content_type('application/x-www-form-urlencoded');
$req->content('wm_command=156');
# Pass request to the user agent and get a response back
my $res = $ua->request($req);
# Check the outcome of the response
if ($res->is_success) {
print $res->content;
}
else {
print $res->status_line, "\n";
}
Well anyway if you have any idea on how to do that in perl or in any other way, I'll be glad to hear from you:D