mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-06 03:27:01 +03:00
add player type 101 - release
This commit is contained in:
Binary file not shown.
@@ -92,11 +92,15 @@ sub init {
|
||||
|
||||
$client->SUPER::init(@_);
|
||||
$client->config_artwork;
|
||||
}
|
||||
$client->send_equalizer;
|
||||
|
||||
main::INFOLOG && $log->is_info && $log->info("SqueezeESP player connected: " . $client->id);
|
||||
}
|
||||
|
||||
sub initPrefs {
|
||||
my $client = shift;
|
||||
$sprefs->client($client)->init($defaultPrefs);
|
||||
$prefs->client($client)->init( { equalizer => [(0) x 10] } );
|
||||
$client->SUPER::initPrefs;
|
||||
}
|
||||
|
||||
@@ -146,6 +150,15 @@ sub treble {
|
||||
return $value;
|
||||
}
|
||||
|
||||
sub send_equalizer {
|
||||
my ($client, $equalizer) = @_;
|
||||
|
||||
$equalizer ||= $prefs->client($client)->get('equalizer') || [(0) x 10];
|
||||
my $size = @$equalizer;
|
||||
my $data = pack("c[$size]", @{$equalizer});
|
||||
$client->sendFrame( eqlz => \$data );
|
||||
}
|
||||
|
||||
sub update_equalizer {
|
||||
my ($client, $value, $index) = @_;
|
||||
return if $client->tone_update;
|
||||
|
||||
@@ -31,7 +31,7 @@ sub page {
|
||||
sub prefs {
|
||||
my ($class, $client) = @_;
|
||||
my @prefs;
|
||||
push @prefs, qw(width small_VU) if defined $client->displayWidth;
|
||||
push @prefs, qw(width small_VU) if $client->displayWidth;
|
||||
return ($prefs->client($client), @prefs);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ sub handler {
|
||||
my ($cprefs, @prefs) = $class->prefs($client);
|
||||
|
||||
if ($paramRef->{'saveSettings'}) {
|
||||
if (defined $client->displayWidth) {
|
||||
if ($client->displayWidth) {
|
||||
$cprefs->set('small_VU', $paramRef->{'pref_small_VU'} || 15);
|
||||
my $spectrum = {
|
||||
scale => $paramRef->{'pref_spectrum_scale'} || 25,
|
||||
@@ -76,7 +76,7 @@ sub handler {
|
||||
$client->update_tones($equalizer);
|
||||
}
|
||||
|
||||
if (defined $client->displayWidth) {
|
||||
if ($client->displayWidth) {
|
||||
# the Settings super class can't handle anything but scalar values
|
||||
# we need to populate the $paramRef for the other prefs manually
|
||||
$paramRef->{'pref_spectrum'} = $cprefs->get('spectrum');
|
||||
|
||||
@@ -25,7 +25,7 @@ $prefs->migrateClient(1, sub {
|
||||
});
|
||||
|
||||
$prefs->setChange(sub {
|
||||
send_equalizer($_[2]);
|
||||
$_[2]->send_equalizer;
|
||||
}, 'equalizer');
|
||||
|
||||
sub initPlugin {
|
||||
@@ -40,8 +40,10 @@ sub initPlugin {
|
||||
}
|
||||
|
||||
$class->SUPER::initPlugin(@_);
|
||||
Slim::Networking::Slimproto::addPlayerClass($class, 100, 'squeezeesp32', { client => 'Plugins::SqueezeESP32::Player', display => 'Plugins::SqueezeESP32::Graphics' });
|
||||
main::INFOLOG && $log->is_info && $log->info("Added class 100 for SqueezeESP32");
|
||||
# no name can be a subset of others due to a bug in addPlayerClass
|
||||
Slim::Networking::Slimproto::addPlayerClass($class, 100, 'squeezeesp32-basic', { client => 'Plugins::SqueezeESP32::Player', display => 'Plugins::SqueezeESP32::Graphics' });
|
||||
Slim::Networking::Slimproto::addPlayerClass($class, 101, 'squeezeesp32-graphic', { client => 'Plugins::SqueezeESP32::Player', display => 'Slim::Display::NoDisplay' });
|
||||
main::INFOLOG && $log->is_info && $log->info("Added class 100 and 101 for SqueezeESP32");
|
||||
|
||||
# register a command to set the EQ - without saving the values! Send params as single comma separated list of values
|
||||
Slim::Control::Request::addDispatch(['squeezeesp32', 'seteq', '_eq'], [1, 0, 0, \&setEQ]);
|
||||
@@ -50,9 +52,6 @@ sub initPlugin {
|
||||
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['newmetadata'] ] );
|
||||
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['playlist'], ['open', 'newsong'] ]);
|
||||
Slim::Control::Request::subscribe( \&onStopClear, [ ['playlist'], ['stop', 'clear'] ]);
|
||||
|
||||
# the custom player class is only initialized if it has a display - thus we need to listen to connect events in order to initializes other player prefs
|
||||
Slim::Control::Request::subscribe( \&onPlayer,[ ['client'], [ 'new', 'reconnect' ] ] );
|
||||
}
|
||||
|
||||
sub onStopClear {
|
||||
@@ -64,20 +63,6 @@ sub onStopClear {
|
||||
}
|
||||
}
|
||||
|
||||
sub onPlayer {
|
||||
my $request = shift;
|
||||
my $client = $request->client || return;
|
||||
|
||||
if ($client->model eq 'squeezeesp32') {
|
||||
main::INFOLOG && $log->is_info && $log->info("SqueezeESP player connected: " . $client->id);
|
||||
|
||||
$prefs->client($client)->init( {
|
||||
equalizer => [(0) x 10],
|
||||
} );
|
||||
send_equalizer($client);
|
||||
}
|
||||
}
|
||||
|
||||
sub onNotification {
|
||||
my $request = shift;
|
||||
my $client = $request->client || return;
|
||||
@@ -104,18 +89,7 @@ sub setEQ {
|
||||
$eqParams[$x] ||= 0;
|
||||
}
|
||||
|
||||
send_equalizer($client, \@eqParams);
|
||||
}
|
||||
|
||||
sub send_equalizer {
|
||||
my ($client, $equalizer) = @_;
|
||||
|
||||
if ($client->model eq 'squeezeesp32') {
|
||||
$equalizer ||= $prefs->client($client)->get('equalizer') || [(0) x 10];
|
||||
my $size = @$equalizer;
|
||||
my $data = pack("c[$size]", @{$equalizer});
|
||||
$client->sendFrame( eqlz => \$data );
|
||||
}
|
||||
$client->send_equalizer(\@eqParams);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -10,6 +10,6 @@
|
||||
<name>PLUGIN_SQUEEZEESP32</name>
|
||||
<description>PLUGIN_SQUEEZEESP32_DESC</description>
|
||||
<module>Plugins::SqueezeESP32::Plugin</module>
|
||||
<version>0.104</version>
|
||||
<version>0.200</version>
|
||||
<creator>Philippe</creator>
|
||||
</extensions>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?xml version='1.0' standalone='yes'?>
|
||||
<extensions>
|
||||
<plugins>
|
||||
<plugin version="0.104" name="SqueezeESP32" minTarget="7.9" maxTarget="*">
|
||||
<plugin version="0.200" name="SqueezeESP32" minTarget="7.9" maxTarget="*">
|
||||
<link>https://github.com/sle118/squeezelite-esp32</link>
|
||||
<creator>Philippe</creator>
|
||||
<sha>79e505a30d7b6dbf43893acab176d57438e2a4a1</sha>
|
||||
<sha>ab2d65f5ba8e73f0f78a1a8650af19ebb1e8e724</sha>
|
||||
<email>philippe_44@outlook.com</email>
|
||||
<desc lang="EN">SqueezeESP32 additional player id (100)</desc>
|
||||
<url>http://github.com/sle118/squeezelite-esp32/raw/master/plugin/SqueezeESP32.zip</url>
|
||||
|
||||
Reference in New Issue
Block a user