artwork support - release

This commit is contained in:
philippe44
2020-03-19 16:13:59 -07:00
parent 5e5dc9ba29
commit 606f1983c5
9 changed files with 40 additions and 25 deletions

View File

@@ -109,7 +109,7 @@ sub build_modes {
my $artwork = $cprefs->get('artwork');
# if artwork is in main display, reduce width
$width = $artwork->{'x'} - 1 if $artwork->{'enable'} && $artwork->{y} < 32;
$width = $artwork->{'x'} if $artwork->{'enable'} && $artwork->{y} < 32;
my $small_VU = $cprefs->get('small_VU');
my $spectrum = $cprefs->get('spectrum');
@@ -119,7 +119,7 @@ sub build_modes {
};
my $small_VU_pos = { x => $width - int ($small_VU * $width / 100),
width => int ($small_VU * $width / 100),
};
};
my @modes = (
# mode 0

View File

@@ -42,6 +42,11 @@ sub hasScrolling {
return 1;
}
sub reconnect {
my $client = shift;
$client->pluginData('artwork_md5', '');
$client->SUPER::reconnect(@_);
}
sub directMetadata {
my $client = shift;

View File

@@ -54,6 +54,9 @@ sub handler {
$cprefs->set('artwork', $artwork);
$client->display->modes($client->display->build_modes);
$client->display->update;
# force update
Plugins::SqueezeESP32::Plugin::update_artwork($client, 1) if $artwork->{'enable'};
}
# as there is nothing captured, we need to re-set these variables

View File

@@ -33,38 +33,44 @@ sub initPlugin {
Slim::Networking::Slimproto::addPlayerClass($class, 100, 'squeezeesp32', { client => 'Plugins::SqueezeESP32::Player', display => 'Plugins::SqueezeESP32::Graphics' });
$log->info("Added class 100 for SqueezeESP32");
Slim::Control::Request::subscribe(\&update_artwork, [ ['newmetadata'] ] );
Slim::Control::Request::subscribe(\&update_artwork, [ ['playlist'], ['open', 'newsong'] ]);
Slim::Control::Request::subscribe(\&onNotification, [ ['newmetadata'] ] );
Slim::Control::Request::subscribe(\&onNotification, [ ['playlist'], ['open', 'newsong'] ]);
}
sub onNotification {
my $request = shift;
my $client = $request->client;
my $reqstr = $request->getRequestString();
$log->info("artwork update notification $reqstr");
#my $path = $request->getParam('_path');
update_artwork($client);
}
sub update_artwork {
my $request = shift;
my $client = $request->client;
my $client = shift;
my $force = shift || 0;
my $cprefs = $prefs->client($client);
my $artwork = $cprefs->get('artwork');
return unless $client->model eq 'squeezeesp32' && $artwork->{'enable'};
my $reqstr = $request->getRequestString();
#my $path = $request->getParam('_path');
my $s = $artwork->{'y'} >= 32 ? $cprefs->get('height') - $artwork->{'y'} : 32;
$s = min($s, $cprefs->get('width') - $artwork->{'x'});
my $path = 'music/current/cover_' . $s . 'x' . $s . '_o.jpg';
my $body = Slim::Web::Graphics::artworkRequest($client, $path, undef, \&send_artwork, undef, HTTP::Response->new);
my $body = Slim::Web::Graphics::artworkRequest($client, $path, $force, \&send_artwork, undef, HTTP::Response->new);
send_artwork($client, undef, \$body) if $body;
$log->info("artwork update notification $reqstr with $path");
}
sub send_artwork {
my ($client, $params, $dataref) = @_;
my ($client, $force, $dataref) = @_;
# I'm not sure why we are called so often, so only send when needed
my $md5 = md5($$dataref);
return if $client->pluginData('artwork_md5') eq $md5;
return if $client->pluginData('artwork_md5') eq $md5 && !$force;
$client->pluginData('artwork', $dataref);
$client->pluginData('artwork_md5', $md5);

Binary file not shown.

View File

@@ -10,6 +10,6 @@
<name>PLUGIN_SQUEEZEESP32</name>
<description>PLUGIN_SQUEEZEESP32_DESC</description>
<module>Plugins::SqueezeESP32::Plugin</module>
<version>0.40</version>
<version>0.41</version>
<creator>Philippe</creator>
</extensions>