View Full Version : Yac2Slim and multiple players

Jeffrey R. Olson
2004-02-02, 22:12
I was able to throw together a quick'n'dirty Perl script to retrieve the
player addresses via the command line interface and then display a string on
all of them. It appears to work. I was going to even try to use this
script in place of Yac2Slim.exe temporarily, but I couldn't seem to get the
modified Yac.exe to call the Perl script when the phone rings. Oh well...

Anyway, Rod, I hope this is at least somewhat helpful to you as you make the
changes to Yac2Slim to support multiple players.


##### Begin Perl

use strict;
use warnings;
use Net::Telnet;
use URI::Escape;

# Configuration
my $server = 'basil';
my $pause = 0;
my $displayTime = 3;

# Get line to display
my $line1 = uri_escape('********* THE PHONE IS RINGING *********');
my $line2 = uri_escape(shift);

# Connection to SlimServer
my $telnet = Net::Telnet->new(Timeout => 10,
Prompt => '/\n/', # Had to guess at this!
Host => $server,
Port => 9090);

# Get all MAC addresses of players
my @playerMACs;
my @output = $telnet->cmd("player count ?");
my $numPlayers = $output[0];
$numPlayers =~ s/player count //;
for (my $i = 0; $i < $numPlayers; $i++) {
my @output = $telnet->cmd("player id $i");
my $MAC = $output[0];
$MAC =~ s/^player id $i //;
$playerMACs[$i] = $MAC;
print $MAC . "\n";

# Pause
if ($pause) {
foreach my $MAC (@playerMACs) {
#print "pausing\n";
$telnet->cmd("$MAC pause 1");

# Display
foreach my $MAC (@playerMACs) {
print "displaying on $MAC\n";
$telnet->cmd("$MAC display $line1 $line2 $displayTime");

# Unpause
if ($pause) {
foreach my $MAC (@playerMACs) {
#print "unpausing\n";
$telnet->cmd("$MAC pause 0");

##### End Perl