-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsqueeze_remote.pl
executable file
·91 lines (82 loc) · 2.37 KB
/
squeeze_remote.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/perl
use Modern::Perl;
use FindBin; # locate this script
use lib "$FindBin::Bin/lib";
use Squeeze;
use Data::Dumper;
my @order = qw{e r n p j l sp pp};
my $s = Squeeze->new();
my $playerId = 'd0:df:9a:0f:e0:ba';
my $exit = 1;
my %things = (
'e' => { short => 'exit',
command => sub {$exit = 0}
},
'n' => { short => 'next track',
command => sub {$_[0]->nextTrack( $_[1] )}
},
's' => { short => 'stop',
command => sub {$_[0]->stop( $_[1] )}
},
,
'p' => { short => 'previous track',
command => sub {$_[0]->prevTrack( $_[1] )}
},
,
'r' => { short => 'refresh',
command => sub { }
},
'l' => { short => 'show playlist',
command => sub {$_[0]->playlist( $_[1] )}
},
'sp' => { short => 'show playlists',
command => sub {my $a = $_[0]->playlists( $_[1] ); say $a}
},
'pp' => { short => 'play playlists',
command => sub {$_[0]->playPlaylist( $_[1], $_[2] )}
},
'shp' => { short => 'shuffle playlists',
command => sub {say $_[0]->shufflePlaylist( $_[1] )}
},
'rp' => { short => 'replay playlists',
command => sub {$_[0]->playTrack( $_[1], 0 )}
},
'j' => { short => 'jump to track number in playlist',
command => sub {$_[0]->playTrack( $_[1], $_[2] )}
},
'rp' => {
short => 'random mix
',
command => sub {$_[0]->randomPlay( $_[1] )}
},
'lp' => {
short => 'list players',
command => sub {
my @a = $_[0]->getPlayerIds();
say "$_ $a[$_]->{name}" for ( 0 .. $#a );
}
},
'selp' => { short => 'list players',
command => sub {$playerId = $_[0]->getPlayerIds( $_[2] );}
},
);
while ($exit)
{
say join ' ', $s->currentTrack($playerId);
say '-' x 20, "\nCommands\n", '-' x 20;
for my $key (@order)
{
say "$key - $things{$key}{short}";
}
my $a = <>;
my $b;
chomp $a;
if ( $a =~ /:/ )
{
( $a, $b ) = split /:/, $a;
}
print "\033[2J";
print "\033[0;0H"; #jump to 0,0
next unless $things{ $a };
$things{ $a }{ command }->( $s, $playerId, $b );
}