Player.pm 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package Plugins::SqueezeESP32::Player;
  2. use strict;
  3. use base qw(Slim::Player::SqueezePlay);
  4. use Slim::Utils::Log;
  5. use Slim::Utils::Prefs;
  6. my $prefs = preferences('plugin.squeezeesp32');
  7. my $log = logger('plugin.squeezeesp32');
  8. sub model { 'squeezeesp32' }
  9. sub modelName { 'SqueezeESP32' }
  10. sub hasIR { 0 }
  11. # Allow the player to define it's display width (and probably more)
  12. sub playerSettingsFrame {
  13. my $client = shift;
  14. my $data_ref = shift;
  15. my $value;
  16. my $id = unpack('C', $$data_ref);
  17. # New SETD command 0xfe for display width & height
  18. if ($id == 0xfe) {
  19. $value = (unpack('Cn', $$data_ref))[1];
  20. if ($value > 100 && $value < 400) {
  21. $prefs->client($client)->set('width', $value);
  22. $client->display->modes($client->display->build_modes);
  23. $client->display->widthOverride(1, $value);
  24. $client->update;
  25. }
  26. my $height = (unpack('Cnn', $$data_ref))[2];
  27. $prefs->client($client)->set('height', $height || 0);
  28. $log->info("Setting player $value" . "x" . "$height for ", $client->name);
  29. }
  30. $client->SUPER::playerSettingsFrame($data_ref);
  31. }
  32. sub hasScrolling {
  33. return 1;
  34. }
  35. sub reconnect {
  36. my $client = shift;
  37. $client->pluginData('artwork_md5', '');
  38. $client->SUPER::reconnect(@_);
  39. }
  40. 1;